简体   繁体   中英

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.

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?

If not what are the alternatives?

Thanks.

The animate method takes a 3rd param called "easing"; learn about it here:

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

Easing can really bring life to an effect. Easing controls how an animation progresses over time by manipulating its acceleration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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