jQuery stop(true, true) to jump to end of all animations in queue

前端 未结 4 1491
野性不改
野性不改 2021-02-14 08:19

I have been using jQuery\'s stop(true, true) method to clear running animations so the next one starts immediately. I noticed that the first parameter, clearQ

4条回答
  •  滥情空心
    2021-02-14 09:04

    Test for presence of class (set upon hover and removed on mouseOut animate callback) before staring new animation. When new animation does start, dequeue.

    $("div").hover(function(){
        if (!$(this).hasClass('animated')) {
            $(this).dequeue().stop().animate({ width: "200px" });
        }
    }, function() {
        $(this).addClass('animated').animate({ width: "100px" }, "normal", "linear", function() {
            $(this).removeClass('animated').dequeue();
        });
    });
    

提交回复
热议问题