You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So there is one quircky thing about SVG when you are trying to get precise information about the position of pointer inside the SVG itself. Namely when you bind event handler to e.g. mousemove you would get for clientX, and clientY with values relative to the document, not the node I have bound my handler to.
This is somewhat normal because SVG uses different units potentially for internal drawing, and you need to transform those units into pixels relative to the SVG it self. Here is how you do it in dirty JS world:
I just wanted to leave a note about this. I have no idea how to fix this nicely.
My quick and dirty solution was to make native module, and stick similar code into it.
Better systematic solution requires much forethought, which I believe you can allocate to the issue. In mean time I will continue thinking about neat solution also :)
Hi,
So there is one quircky thing about SVG when you are trying to get precise information about the position of pointer inside the SVG itself. Namely when you bind event handler to e.g.
mousemove
you would get for clientX, and clientY with values relative to the document, not the node I have bound my handler to.This is somewhat normal because SVG uses different units potentially for internal drawing, and you need to transform those units into pixels relative to the SVG it self. Here is how you do it in dirty JS world:
I just wanted to leave a note about this. I have no idea how to fix this nicely.
My quick and dirty solution was to make native module, and stick similar code into it.
Better systematic solution requires much forethought, which I believe you can allocate to the issue. In mean time I will continue thinking about neat solution also :)
Further reading:
https://www.sitepoint.com/how-to-translate-from-dom-to-svg-coordinates-and-back-again/
The text was updated successfully, but these errors were encountered: