简体   繁体   English

JQuery动画:动画期间可以改变速度吗?

[英]JQuery animation: Is it possible to change speed during the animation?

I want to move a div down a page, and I want it to slow down as it reaches the target. 我想在页面上移动一个div,我希望它在达到目标时减慢速度。

I tried using call back with recursive func but it doesn't look smooth: 我尝试使用递归函数回调,但它看起来不平滑:

function MovePanel() {
    sidePanel.animate({
        "marginTop": newCurrTop
    }, moveSpeed, function () {
        MovePanel();
    });
}

Is it possible to slow down an JQuery animation? 是否可以减慢JQuery动画?

If not what are the alternatives? 如果不是什么选择?

Thanks. 谢谢。

The animate method takes a 3rd param called "easing"; animate方法采用名为“缓和”的第3个参数; learn about it here: 在这里了解它:

http://api.jquery.com/animate/ http://api.jquery.com/animate/

You might want to check this out: http://www.learningjquery.com/2009/02/quick-tip-add-easing-to-your-animations 你可能想看看这个: http//www.learningjquery.com/2009/02/quick-tip-add-easing-to-your-animations

Easing can really bring life to an effect. 宽松可以真正带来生命效果。 Easing controls how an animation progresses over time by manipulating its acceleration. Easing通过操纵其加速来控制动画如何随时间推移。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM