我正在尝试在动画启动时使用步进功能更改jQuery动画的持续时间,例如缓动效果。我创建了一个检查它的示例here is jsFiddle。
$('span').click(function() {
var _this = $(this);
if( !_this.is(':animated') ) {
var target = 400;
var speed = 1000;
_this.animate({'top': target +'px'},{
duration: speed,
step: function(now,fx) {
//what does fx stands for anyway, i cound'nt solve it?
if ( now >= 300 ) { speed=100; }
//condition works but it won't effect the current animation
}
});
}
});