【发布时间】:2011-01-25 23:16:23
【问题描述】:
我想知道围绕中心点以圆周运动为元素设置动画的最佳方式?
我想不通... :(
提前致谢。
神经流。
【问题讨论】:
标签: javascript jquery animation
我想知道围绕中心点以圆周运动为元素设置动画的最佳方式?
我想不通... :(
提前致谢。
神经流。
【问题讨论】:
标签: javascript jquery animation
使用jquery.path插件,这里是demo。
(从另一个问题中找到:How would you animate something so that it follows a curve?)
【讨论】:
$.path is undefined。这似乎是由 NoScript 中的 nosniff 阻塞引起的。
我能想到的最简单的是:
简单演示:
var elem = $('h1:eq(0)')
.append('<span id="round" style="position:absolute;background-color:red;"> </span>')
.css('position','relative')
.find('span#round');
var i = 0;
setInterval(function(){
++i;
elem.css({'left': Math.sin(i * 0.02) * 100, 'top': Math.cos(i * 0.02) * 100});}, 100);
在jsfiddle查看它的实际应用。
【讨论】: