JS 橡皮筋效果,有人知道吗?
给定一个 div“square”
鉴于我已经在该 div 上有一个 touchmove
函数,并且我可以实时检测位置 X:
如何实现橡皮筋效果?
我的意思是:点击并向左拖动,直到阻力达到极限,如果松开手指,square div
将通过缓动动画返回到其初始位置,
有一个简单的数学吗?或者插件?
如果可能的话,不使用jquery更新
会更好
Given a div "square"
and given I already have a touchmove
function on that div and I can detect the position X in real time:
how can I implement the rubber band effect?
I mean: tap and drag to the left until the resistance reach the limit and if ou release the finger the square div
goes back to its initial position with an easing animation
there is a simple math for that? or a plugin?
UPDATE
w/o jquery would be better if possible
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其原始位置存储在某处。
然后在拖尾事件上:
演示:http://jsfiddle.net/maniator/T8zYt/
完整代码(使用 jQuery
draggable
):Store its original position somewhere.
Then on the dragend event:
Demo: http://jsfiddle.net/maniator/T8zYt/
Full code (with jQuery
draggable
):