jQuery暂停/恢复动画

Sur*_*raj 12 javascript jquery jquery-animate

这对我不起作用......

$(document).ready(function(){
    $('#h .a').animate({
        top:'-=80px'
    },90,'linear');

    $('#h .au,#h .di').animate({
        left:'-=80px'
    },50000000,'linear');

    $('#h .r').animate({
        left:'-=80px'
    },250,'linear');

    $("#h").animate('pause'); //pausing it at the start
    //resume pause switch
    $("#h").mouseover(function(){
      $(this).animate('resume');
    }).mouseout(function(){
      $(this).animate('pause');
    });

});
Run Code Online (Sandbox Code Playgroud)

Shi*_*TCo 11

尝试这个暂停和恢复:jQuery暂停/恢复动画插件

我们$(this).stop()也可以暂停动画,但没有机会恢复!

另一个错误就是这个: top:'-=80px'

首先尝试获得这样的当前位置然后添加位置:

_top = $(this).offset().top;

$('#h .a').animate({
    top:_top-80
},90,'linear')
Run Code Online (Sandbox Code Playgroud)


Ada*_*son 4

在这里查看演示: http: //api.jquery.com/clearQueue/

看起来正是您正在尝试做的事情。