当前位置:网站首页>Browser scrolling for more implementations
Browser scrolling for more implementations
2022-07-02 06:41:00 【The health of the bright moon in Qin Dynasty】
List of articles
One 、 Code implementation
The following code is based on my common UI frame vue Realized , If you are another framework , Directly extract the key code of scrolling , Be careful crollPoint
added 0.5 It is compatible with the built-in browser of enterprise wechat , When the built-in browser of enterprise wechat scrolls to the bottom for the first time , Variable crollPoint
and totalPageHeight
Values are as follows :
TYPE | ASCII |
---|---|
scrollPoint | 1600.6666870117188 |
Quotes | 1601 |
You can see that if you don't add 0.5
, scrollPoint >= totalPageHeight It's not true , You can't roll load .
<template>
<div></div>
</template>
<script>
export default {
data() {
return {
data: [],
oriData: [],
page: {
total: 0,
pageSize: 10, // Scroll load once 10 Data
current: 1,
},
};
},
mounted() {
document.addEventListener('scroll', this.scrollMoreData, false);
},
destroyed() {
document.removeEventListener('scroll', this.scrollMoreData, false);
},
methods: {
scrollMoreData() {
const {
total, current, pageSize } = this.page;
// @var int totalPageHeight
const totalPageHeight = document.body.scrollHeight;
// @var int scrollPoint
const scrollPoint = window.scrollY + window.innerHeight;
// check if we hit the bottom of the page
console.log('scrollPoint >= totalPageHeight', scrollPoint, totalPageHeight);
if (scrollPoint + 0.5 >= totalPageHeight && current * pageSize <= total) {
console.log('at the bottom');
this.data = this.data.concat(this.oriData.slice(current * pageSize, pageSize * (current + 1)));
this.page.current += 1;
}
},
},
};
</script>
<style lang="less" scoped></style>
Two 、 Reference documents
Javascript: How to detect if browser window is scrolled to bottom?
边栏推荐
- 广告业务Bug复盘总结
- 实习生跑路留了一个大坑,搞出2个线上问题,我被坑惨了
- 看完有用的blog
- Eggjs -typeorm 之 TreeEntity 实战
- Fe - weex uses a simple encapsulated data loading plug-in as the global loading method
- Selenium+msedgedriver+edge browser installation driver pit
- 记录一次RDS故障排除--RDS容量徒增
- Distributed transactions: the final consistency scheme of reliable messages
- Virtualenv and pipenv installation
- 奇葩pip install
猜你喜欢
Data science [9]: SVD (2)
CTF three count
Win10桌面图标没有办法拖动(可以选中可以打开可以删除新建等操作但是不能拖动)
Redis - hot key issues
Latex 编译报错 I found no \bibstyle & \bibdata & \citation command
默认google浏览器打不开链接(点击超链接没有反应)
Solution to the black screen of win computer screenshot
Sublime Text 配置php编译环境
Redis——大Key问题
qq邮箱接收不到jenkins构建后使用email extension 发送的邮件(timestamp 或 auth.......)
随机推荐
记录一次RDS故障排除--RDS容量徒增
Pytest (1) case collection rules
AWD learning
Render minecraft scenes into real scenes using NVIDIA GPU
web自动中利用win32上传附件
Fe - use of weex development weex UI components and configuration use
CUDA and Direct3D consistency
When requesting resttemplate, set the request header, request parameters, and request body.
Code skills - Controller Parameter annotation @requestparam
Alibaba cloud MFA binding Chrome browser
Storage space modifier in CUDA
After reading useful blogs
Fe - eggjs combined with typeorm cannot connect to the database
CUDA中的存储空间修饰符
代码技巧——Controller参数注解@RequestParam
Fe - weex uses a simple encapsulated data loading plug-in as the global loading method
Codeforces Round #797 (Div. 3) A—E
Loops in tensorrt
20210306转载如何使TextEdit有背景图片
分布式事务 :可靠消息最终一致性方案