scrollTop 0作为条件语句

时间:2013-04-22 23:01:55

标签: jquery scrolltop

我正在尝试.animate(提供两个条件为真)或(else).fadeOut元素:

if (window.location.hash == '' && window.scrollTop() == '0') {
     //do .animate

if (window.location.hash == '' && (window).scrollTop() == '0') {
     //do .animate

第一个工作,但窗口scrollTop我无法以适当的方式编写语法。

-Greta

P.S。这是整个代码。除了顶部的scrollTop部分外,一切正常:

   if (window.location.hash == '' || $(window).scrollTop() == '0') {

        $('#preloader').delay(3000).animate({
                        width:'792px', left:'50%', top:'-.5cm', marginLeft:'-396px', opacity:'0.75'},600,'easeOutExpo').animate({        
                        height:'0px', top:'13cm', opacity:'0'}, 400, 'easeOutExpo', function(){ 
                $(this).remove();
        }); 
        $('#headerwrapper').addClass('delay55sec animated250 entryShot easeInExpo');
        $('#foot').animate({top:'-16cm'},0,'').delay(3700).animate({top:'0'},900,'easeOutBounce');
        $('.block-menu li a').animate({left:'-20cm'},0,'').delay(4000).animate({left:'0px'},1234,'easeInOutExpo');
        $('.bodoni').fadeTo(0, 0).delay(5000).fadeTo(1555, 1.0);  
        $('#content').hide(0).delay(5000).slideDown(999, 'easeInExpo');
        $('#nav').animate({left:'-1500px'},0,'').delay(6000).animate({'left': '0px'}, 1555, 'easeOutBounce');  

  } else {

        $.scrollTo($(window.location.hash+"_"), 4444, {axis:'y', easing:'easeInOutQuint'}); 
        $('#preloader').delay(600).fadeOut(3000, function(){ 
                $(this).remove();
        });            
  }

0 个答案:

没有答案