我正在使用.animate方法将div 100px向右移动1秒以上.
因此,每10毫秒1px.是否发生每次像素移动后都会触发的事件?甚至是每移动10-20px后触发的事件?
上面的示例很简单,我将使用它来跟踪多个元素的left:属性,并确定何时仅在浏览器的可见范围内显示它们.
解决方法:
step function in animate是您所需要的(您必须为此向下滚动一点)
The second version of .animate()
provides a step option — a callback
function that is fired at each step of
the animation. This function is useful
for enabling custom animation types or
altering the animation as it is
occurring. It accepts two arguments
(now and fx), and this is set to the
DOM element being animated.
$(something).animate({
..... settings...
},
{
{
step: function(now, fx) {
// where your code goes
}
});