Created
July 31, 2019 10:52
-
-
Save stefanRepac/ac73cc2c9ac5ee9e55cc51659527d4f5 to your computer and use it in GitHub Desktop.
Convert SVG <rect> x,y cordinate to HTML cordinate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Convert SVG <rect> x,y cordinate to HTML cordinate | |
| var svg = this; | |
| var svg_el = document.getElementsByClassName(element_class); | |
| var rootSVG = document.querySelector("#front-view svg"); | |
| var point = rootSVG.createSVGPoint(); | |
| var matrix, position; | |
| matrix = svg_el[0].getCTM(); | |
| point.x = svg.attr('x'); | |
| point.y = svg.attr('y'); | |
| position = point.matrixTransform(matrix); | |
| el.style.left = position['x'] + 'px'; | |
| el.style.top = position['y'] + 'px'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment