Skip to content

Instantly share code, notes, and snippets.

@lyuehh
Created May 25, 2012 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyuehh/2786388 to your computer and use it in GitHub Desktop.
Save lyuehh/2786388 to your computer and use it in GitHub Desktop.
scroll in ie
scroll: function(start, end) { // 是否在滚动的标志位
var _scroll = false; // 初始化获取滚动的高度
var _top = $(document).scrollTop(); // 监听滚动是否开始结束
var _scroll = setInterval(function() {
var __top = $(document).scrollTop();
if (!_scroll && _top != __top) { // 滚动开始
_scroll = true;
if (typeof start == 'function') start();
}
if (_scroll && _top == __top) {
_scroll = false;
if (typeof end == 'function') end();
}
_top = __top;
}, 100); // 采用bind滚动的方式
$(window).bind('scroll', function(e) { // alert('scrolling...');
if (!_scroll) { // alert('scroll...');
start();
_scroll = true;
}
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment