SVG 鼠标指针位置
我想知道如何使用 JavaScript 找出鼠标指针在 SVG viewBox 范围内时的位置。 我是否需要使用事件模型来跟踪所有各种鼠标运动事件,或者是否有一种方法可以轮询鼠标指针,让它在需要时告诉我它在哪里?
I would like to know how I can use JavaScript to find out the location of the mouse pointer when it is within the bounds of an SVG viewBox. Do I need to use the event model to keep track of all the various mouse motion events, or is there a way I can poll the mouse pointer to have it tell me where it is when I need it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以挂钩
onmousemove
事件并访问事件对象:(假设
on_mouse_move
连接到 SVG 文档的onmousemove
事件)。You can hook to the
onmousemove
event and access the event object:(This assumes
on_mouse_move
is connected to theonmousemove
event of your SVG document).