2012-12-05 52 views
1

這裏是我的代碼, 這段代碼從頁面底部滾動div到頂部。 我有3個鏈接,每個滾動另一個div並隱藏它後面的div。 如果等到動畫結束,所有的作品都很好。 如果我不等,我很快點擊鏈接,它不起作用。 動畫卡住,有時它不顯示任何div。當快速點擊鏈接時Jquery動畫無法正常工作

可能是什麼問題?

的CSS:

.footerDiv{ 
display:none; 
position:absolute; 
z-index:900; 
top:800px; 
left:0px; 
background-size:100%; 
height: 600px; 
width:100%; 
margin: 0; 
padding: 0; 
background-repeat:no-repeat; 
background-position:bottom;} #fourth{background-image:url(../images/group_bg.jpg);} #fifth{background-image:url(../images/team_bg.jpg);} #sixth{background-image:url(../images/client_bg.jpg);} 

的JavaScript:

function showFooterLink(num){ 
var bottomOfScroll = $(window).scrollTop() + $(window).height(); 

$("#footerLinks a").each(function(index, element) { 
    var elemNum = $(element).attr("data-num"); 
    if(elemNum==num){ 
     $(element).addClass("on"); 
    } 
    else{ 
     $(element).removeClass("on"); 
    } 
}); 

$('.footer_'+num).stop(). 
    css({ 
     "display":"block", 
     "z-index":1000 
    }). 
    animate({ 
     top: bottomOfScroll - $(window).height() 
    }, { 
    duration: 1500, 
    specialEasing: { 
     top: 'easeInOutQuad' 
    }, 
    complete: function() { 

     $("body").css("overflow", "hidden"); 
     $(".footerDiv").each(function(index, element) { 
      if(!$(element).hasClass("footer_"+num)){ 
       $(element).hide(); 
       $(element).css({ 
        "top"  : bottomOfScroll, 
        "z-index" : 900 
       }); 
      } 
      else{ 
       $(element).css("z-index","900"); 
      } 
     }); 
    } 
}); 

}

回答

2

嘗試通過一些布爾到停止方法:

變化

stop() 

stop(true, true) 

第一布爾將清除動畫隊列。第二部分將「動畫結束」,從而防止動畫卡在「中間」某處。

clearQueue指示是否也刪除排隊動畫的布爾值。默認爲false。

jumpToEnd布爾值,指示是否立即完成當前動畫。默認爲false。

更多信息here

+0

_I加入它,但它並沒有help._ 你可以在這裏看到的網站:[鏈接](http://91.202.171.113/$sitepreview/ben-natan。 com/recreate-nikebetterworld-parallax/index.html) 鏈接以頁面底部的希伯來語顯示。 – Dushy

+0

@ user1879725'您正在查找的頁面可能已被刪除,名稱已更改或暫時不可用。「 – Johan

+0

請參閱鏈接:http://91.202.171.113/$sitepreview/ben-natan.com/recreate -nikebetterworld-parallax/index.html – Dushy