当前位置:网站首页>Js 监听滚动触底加载更多_浏览器滚动触底加载更多
Js 监听滚动触底加载更多_浏览器滚动触底加载更多
2022-06-11 20:37:00 【天马3798】
一、Js 监听滚动触底加载更多_浏览器滚动触底加载更多
滚动监听原理:
监听浏览器滚动 scroll, 当滚动条滚动高度+可视高度 >= 文档高度 时候触发
//触底加载更多
function loadMore() {
alert('到底了');
console.error('滚动到最低了');
}
//监听浏览器滚动 scroll, 当滚动高度+可视高度 >= 文档高度 时候触发
document.addEventListener('scroll', function (e) {
var scrollTop = getScrollTop();
var winHeight = getWindowHeight();
var docHeight = getDocumentHeight();
//console.info(`滚动高度:${scrollTop} 可视高度:${winHeight} 文档高度:${docHeight}`);
if ((scrollTop + winHeight) >= docHeight) {
//由于滚动条不问,注意处理重复触底问题
loadMore();
}
}, false);
//获取页面高度
function getDocumentHeight() {
//现代浏览器(IE9+和其他浏览器)和IE8的document.body.scrollHeight和document.documentElement.scrollHeight都可以
return Math.max(document.body.scrollHeight, document.d边栏推荐
- 修改本地微信小程序的AppID
- Redis第四话 -- redis高性能原理(多路复用)和高可用分析(备份、主从)
- moderlarts第一次培训
- Web3 product manager guide - Jason
- Role of RESNET residual block
- 29. location object
- Wechat applet Bluetooth development
- Chinese text classification based on CNN
- [Monday commuter radio station] cron expression. It's enough to read this article
- Flutter doctor 显示xcode没有安装的解决办法
猜你喜欢

The principle that the picture of QQ Post Bar changes when it is opened

Power supply anti reverse connection and anti backflow - use MOS tube and op amp to realize ideal diode

Redis第四话 -- redis高性能原理(多路复用)和高可用分析(备份、主从)

sql优化之DATE_FORMAT()函数

Leetcode2027. Minimum number of operations to convert a string (yes, once)

浅聊对比学习(Contrastive Learning)第一弹

In unity, opencv and QT are used to create a plugin (I)

Simulate Oracle lock waiting and manual unlocking

银泰百货与淘宝天猫联合打造绿色潮玩展,助力“碳中和”

修改本地微信小程序的AppID
随机推荐
In 2021, the global revenue of flexible fireproof sealant is about 755.2 million dollars, and it is expected to reach 1211.7 million dollars in 2028
STC hardware only automatic download circuit V2
Rule engine mode Net open source project case
26. 定时器
Unity package manager starting server stuck
VS2010 cannot open when linking sql2008 database
上海内推 | 上海期智研究院于洋老师课题组招收全职研究员
Wechat applet Bluetooth development
Wechat applet | rotation chart
15 r exercise
Shanghai internal promotion 𞓜 Yuyang teacher's research group of Shanghai Chizhi research institute recruits full-time researchers
28. JS implementation mechanism
ICML 2022 | 基于结构化数据的异常检测再思考:我们究竟需要怎样的图神经网络?...
Detailed tutorial on installing MySQL database in Linux environment (including uninstallation and password reset process)
Unified exception handling
Solution to unlimited restart of desktop and file explorer
Modify appid of local wechat applet
File upload vulnerability - simple exploitation 2 (Mozhe college shooting range)
Title does not display after toolbar replaces actionbar
moderlarts第二次作业