2011-12-22 7 views
0

jQuery를 사용하여 DIV가 표시하는 것처럼 # 페이지가 보이지 않도록 페이지를 충분히 아래로 스크롤하면 어떻게 할 수 있습니까? .watch 이벤트가 먼저 트리거해야합니다, 당신은 스크롤 할 때 다른 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); 
    }); 
}); 

그래서 그냥 표시 할 수 없습니다 유일한 조건은 내 코드입니다. 어떻게해야합니까?

답변

1

을 사용하여 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 
     }  
    }); 
});