hyj1412's Blog

record, write and share.


  • Home

  • Tags

  • Categories

  • Archives

window scroll事件

Posted on 2014-08-11 | Edited on 2019-04-09 | In web , js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 滚动条滑动到底部,开始加载
$(window).on('scroll', function(){
var docHeight = Drupal.verycdn_tools.getDocHeight();
var scrollTop = $(this).scrollTop();
var winHeight = $(this).height();
if(scrollTop >= docHeight - winHeight) {
//TODO
}
});

Drupal.verycdn_tools.getDocHeight = function () {
var doc = document;
return Math.max(
Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight),
Math.max(doc.body.offsetHeight, doc.documentElement.offsetHeight),
Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
);
}
1…1011

hyj1412

记录生活,书写心得,分享成果
51 posts
26 categories
48 tags
Creative Commons
© 2022 hyj1412 |
Creative Commons
Powered by Hexo v3.9.0
|
Theme – NexT.Muse v7.1.0