Javascript用鼠标坐标旋转图像
我使用视差效果,根据用户鼠标位置移动球(http://webdev.stephband.info/jparallax/index.html)。我正在想办法让球也旋转。因此,当用户将鼠标移到该区域上时,球就会在屏幕上滚动。
我发现了一些 javascript 示例,展示了如何通过单击鼠标来旋转项目,我只是在 js 方面不够熟练,无法将它们组合在一起。
这是一个显示示例的 Jsfiddle:
Im using a parallax effect that moves a ball according to the users mouse position (http://webdev.stephband.info/jparallax/index.html). I am trying to figure out a way that the ball will also rotate. So it would appear that as the user moves their mouse over the area, the ball rolls across the screen.
I have found some javascript examples that show how to rotate an item on mouse click, I am just not skiled enough in js to put it all together.
here is a Jsfiddle that shows an example:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这与其说是答案,不如说是切题建议,但为了使滚动的球看起来更真实,请确保它以与球的圆周一致的速度旋转。不然会显得很假。
This is more tangential advice than an answer, but in order to make the rolling ball look realistic, make sure that it rotates at a rate that is consistent with the ball's circumference. Otherwise it will look fakey.
这个 jQuery 插件可能会很有用。
This jQuery plugin might be useful.