2011-12-22 46 views
0

jQueryを使用してDIVが表示されるようにページの下側にスクロールすると(#表示が見えないように)、どうすればいいですか?唯一の条件は、私のコードです:別のDIVが表示されていない場合にDIVを表示

jQuery(function($){ 
    $("#fake").watch('width', function(){ 
     $('#notibubble').fadeIn(250, function() { 
      $('#notibubble').delay(1450).fadeOut(250, function() { 
       // Animation complete. 
      }); 
     }); 
     $("#notification").effect("pulsate", { times:3}, 500); 
    }); 
}); 

あなたがスクロールするときに、それだけで表示することができない、.watchイベントが最初にトリガする必要があります。これどうやってするの?

答えて

1

.data()を使用して、watchイベントがトリガされた場合に格納できます。それでは、あなたの.scroll()関数でこれをチェックするだけです。

jQuery(function($){ 
    $("#fake").watch('width', function(){ 
     // current watch function 

     // store that a watch event has fired 
     $("#notification").data('watched', true); 
    }); 

    $(window).scroll(function(){    
     if($("#notification").data('watched') === true){ 
      // Check if #notification is out of view by using the window's 
      // scrollTop() and the current position and height of #notification 
     }  
    }); 
}); 
関連する問題