当前位置:网站首页>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?
边栏推荐
- Redis - big key problem
- Kotlin - 验证时间格式是否是 yyyy-MM-dd HH:mm:ss
- TensorRT的命令行程序
- 2020-9-23 QT的定时器Qtimer类的使用。
- 提高用户体验 防御性编程
- Pytest (1) case collection rules
- Golang -- map capacity expansion mechanism (including source code)
- 计算属性普通函数写法 和 set get 写法
- DeprecationWarning: .ix is deprecated. Please use.loc for label based indexing or.iloc for positi
- 构建学习tensorflow
猜你喜欢

Présence d'une panne de courant anormale; Problème de gestion de la fsck d'exécution résolu

蚂蚁集团g6初探

Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem

AWD learning

Pytest (1) case collection rules

Apt command reports certificate error certificate verification failed: the certificate is not trusted

Uploading attachments using Win32 in Web Automation

Linked list (linear structure)

Alibaba cloud MFA binding Chrome browser

Win10桌面图标没有办法拖动(可以选中可以打开可以删除新建等操作但是不能拖动)
随机推荐
Storage space modifier in CUDA
Alibaba cloud MFA binding Chrome browser
AWD learning
Kali latest update Guide
CUDA中的动态全局内存分配和操作
There are multiple good constructors and room will problem
华为MindSpore开源实习机试题
pytest(2) mark功能
Eggjs -typeorm 之 TreeEntity 实战
Pytest (3) parameterize
When requesting resttemplate, set the request header, request parameters, and request body.
ZZQ的博客目录--更新于20210601
AWD学习
日志 - 7 - 记录一次丢失文件(A4纸)的重大失误
Fe - use of weex development weex UI components and configuration use
unittest.TextTestRunner不生成txt测试报告
TensorRT的数据格式定义详解
virtualenv和pipenv安装
Sentinel Alibaba open source traffic protection component
Kotlin - verify whether the time format is yyyy MM DD hh:mm:ss