퍼블리싱/JS & JQ

스크롤 종료를 감지하는 스크립트

Slyeee 2018. 10. 24. 17:12

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$.fn.scrollEnd = function(callback, timeout) {
    $(this).scroll(function(){
      var $this = $(this);
      if ($this.data('scrollTimeout')) {
        clearTimeout($this.data('scrollTimeout'));
      }
 
      $this.data('scrollTimeout'setTimeout(callback,timeout));
    }); // 스크롤종료시를 감지하는 스크립트
};
 
 
$(window).scrollEnd(function(){
    // Todo Script
}, 2000);
cs