JS tween如何改进?
我正在尝试制作一个简单的博览会补间,它可以工作,但它有点紧张,FF 似乎有点挂起。我可以做什么来改善它?
var distance = (target - x) * dir;
x += (distance / 5) * dir;
if (dir == 1 && x >= target-1) {
return;
}
if (dir == -1 && x <= target+1) {
return;
}
Im trying to make a simple expo tween, it works, but its a bit jittery and FF seems to hang a bit. What can I do to improve it?
var distance = (target - x) * dir;
x += (distance / 5) * dir;
if (dir == 1 && x >= target-1) {
return;
}
if (dir == -1 && x <= target+1) {
return;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能会找到答案以及更多信息,请查看 tween.js
所有补间曲线可视化 的源代码:
http://sole.github.com/tween.js/examples/03_graphs.html
You'll probably find your answer and more looking at the source of tween.js
All tween curves visualized:
http://sole.github.com/tween.js/examples/03_graphs.html
Javascript 算术对于所有浏览器来说都足够快。尝试减少每次迭代更新的 DOM 节点数量。
Javascript arithmetic is fast enough for all browsers. Try reducing the amount of DOM nodes you update per iteration.
我不太确定你在寻找什么,但这也许吗?
I'm not quite sure what you're looking for, but this maybe?