当前位置:网站首页>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?
边栏推荐
- virtualenv和pipenv安装
- kali最新更新指南
- FE - Eggjs 结合 Typeorm 出现连接不了数据库
- Win10网络图标消失,网络图标变成灰色,打开网络设置闪退等问题解决
- Fe - wechat applet - Bluetooth ble development research and use
- unittest.TextTestRunner不生成txt测试报告
- Warp shuffle in CUDA
- Redis——大Key問題
- There are multiple good constructors and room will problem
- web自动化切换窗口时报错“list“ object is not callable
猜你喜欢

默认google浏览器打不开链接(点击超链接没有反应)

Log (common log framework)

Redis——大Key問題

Alibaba cloud MFA binding Chrome browser

The intern left a big hole when he ran away and made two online problems, which made me miserable

Learn about various joins in SQL and their differences

QQ email cannot receive the email sent by Jenkins using email extension after construction (timestamp or auth...)

阿里云MFA绑定Chrome浏览器

Summary of advertisement business bug replay
![[literature reading and thought notes 13] unprocessing images for learned raw denoising](/img/a5/ed26a90b3edd75a37b2e5164f6b7d2.png)
[literature reading and thought notes 13] unprocessing images for learned raw denoising
随机推荐
MySql索引
CUDA user object
Data science [9]: SVD (2)
Log (common log framework)
压力测试修改解决方案
CUDA中的存储空间修饰符
AWD learning
PIP install
[literature reading and thought notes 13] unprocessing images for learned raw denoising
Redis——大Key问题
Flask migrate cannot detect db String() equal length change
由于不正常断电导致的unexpected inconsistency;RUN fsck MANUALLY问题已解决
Redis - grande question clé
Idea announced a new default UI, which is too refreshing (including the application link)
查询GPU时无进程运行,但是显存却被占用了
apt命令报证书错误 Certificate verification failed: The certificate is NOT trusted
Apt command reports certificate error certificate verification failed: the certificate is not trusted
There are multiple good constructors and room will problem
Introduce two automatic code generators to help improve work efficiency
unittest.TextTestRunner不生成txt测试报告