使用jquery根据鼠标坐标移动图像 [英] Move an image according to the mouse cordinates using jquery

查看:145
本文介绍了使用jquery根据鼠标坐标移动图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发HTML5白板。我希望用户查看电路板
,以了解演示者在屏幕中指向的确切位置。我可以使用此jquery功能
收集鼠标移动。

I am trying to develop a HTML5 white board. I want the users viewing the board to know where exactly the presenter is pointing within the screen. I am able to collect the mouse movements using this jquery function.

但即使我成功将这个值
传递给使用php的其他客户端,我该如何模仿呢? 是否可以根据从演示者处获得的坐标移动一个小的
指针图像?

But even if i succeed to pass this values to other clients using php, how can I emulate it? Is it possible to move a small pointer image, based on the co-ordinates obtained from the presenter?


  1. 是否有任何功能或片段无法启动?

  2. 这是一项非常硬件密集型的任务,普通人可能会发生b $ b b问题吗?

  3. 这是实现我想要实现的目标的最佳途径吗?


推荐答案

你可以使用 .css

来移动图像,例如:

$(window).mousemove(function(event) {
  $("#image").css({"left" : event.pageX, "top" : event.pageY});
});

#image 设置为固定或绝对


  1. above

这不是很硬件密集型一点都不只要你使用 .css 而不是 .animate

This is not very hardware intensive at all. As long as you use .css and not .animate

这可能是最简单,最强大的解决方案

This is probably the easiest and most robust solution

这篇关于使用jquery根据鼠标坐标移动图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆