DmitryBaranovskiy / raphael

JavaScript Vector Library
https://dmitrybaranovskiy.github.io/raphael/
MIT License
11.27k stars 1.67k forks source link

element.mousemove #1141

Closed GoldWood2000 closed 2 years ago

GoldWood2000 commented 2 years ago

image Hello, I have a problem, that is, the red circle part on the picture is the position where my mouse is placed, and then the x, y are obtained, and the character a==1 is displayed, but why is the position of x and y not my mouse? The location and the gap is so big, which puzzles me

ibrierley commented 2 years ago

Hard to tell without seeing any code.

GoldWood2000 commented 2 years ago

没有看到任何代码很难说。

image

My need is to show and hide a text at the position of the mouse

ibrierley commented 2 years ago

Is the tip_text inside some svg or other container or element that may be scaled or translated ?

GoldWood2000 commented 2 years ago

Is the tip_text inside some svg or other container or element that may be scaled or translated ?

image

yes, inside an svg,The first red circle part is the position where my mouse is placed on the line, but the obtained x and y are indeed very different from the mouse position. It is expected that a==1 will be displayed in the first red circle.

ibrierley commented 2 years ago

Ok, so you probably need to either move the text outside of the elements that are transforming it, or transform the x,y with the with the inverse of the transform that's affecting it. It's a bit fiddly that stuff (Snap.svg may be slightly easier Raphaels sister package, but you will likely still have to get a bit messy if you can't draw it outside of the elements affecting it).