我可以从每个步骤的 jQuery 动画步骤方法中获得哪些信息?
我有一个垂直的推荐带,我有这个方法,每隔几秒用计算值(取决于当前推荐的高度)为其 top
值设置动画。
现在,当用户将鼠标悬停在其上时,它会立即停止(通过 .stop()
,并且还通过 clearInterval(idOfinterval)
清除间隔
但我仍然想知道在突然停止之前它还剩下多少像素可以进行动画处理。
所以我查了一下文档,我发现有一个步骤
具有回调的方法,可以为我提供有关动画每个(?)步骤的信息。
查看部分代码
//in middle of a object literal
animate:function(){
animAmmount = someCalculation;
testimonialsBelt.parentElment.animate({
top:"-="+howMuchIsLeft||animAmmount+"px"},
{step:function(step){
//here i am trying to get how much px it has moved so far
currTopVal = step;
console.log("currTopVal", currTopVal);
// i get some numbers, and i have no idea from where it got them
}
},
calculatedSpeed);
}
所以我的主要问题是
step
方法的参数中获取哪些信息?I got a vertical testimonials belt and i have this method that animates its top
value with a calculated value (depending on the height of the current testimonial) every few seconds.
Now when a user hovers over it, it stops right away (via .stop()
and also the interval is cleared via clearInterval(idOfinterval)
But i still want to know how much more pixels it had left to animate before it suddenly got halted.
So i looked up in the documentation and i see that there is a step
method that has a callback and can give me information on each(?) step of the animation.
see part of the code
//in middle of a object literal
animate:function(){
animAmmount = someCalculation;
testimonialsBelt.parentElment.animate({
top:"-="+howMuchIsLeft||animAmmount+"px"},
{step:function(step){
//here i am trying to get how much px it has moved so far
currTopVal = step;
console.log("currTopVal", currTopVal);
// i get some numbers, and i have no idea from where it got them
}
},
calculatedSpeed);
}
So my main questions are
step
method?如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来“this”符号将是调用 animate 的元素。回调的第一个参数看起来像在此步骤中动画的属性值。第二个参数是一个对象,如下所示:
It looks like the "this" symbol will be the element animate was called on. The first parameter to the callback looks like the value of the property animated on this step. The second parameter is an object that looks like this: