当前位置:网站首页>[H5 bottom scrolling paging loading]
[H5 bottom scrolling paging loading]
2022-07-26 23:23:00 【shewlong】
Web pages realize rolling paging loading
Waterfall flow scrolling loading , Used to show long lists , When the list is about to scroll to the bottom , Events are triggered and more list items are loaded .

Technical preparation
Core attributes :
scrollTop: The height of the web page being rolled away
clientHeight: The height of the current viewing area
scrollHeight: Document flow height
distance: How far to the bottom of the page to trigger
Determine whether to reach the bottom formula :
scrollTop+clientHeight>=scrollHeight-distance
Specific judgment method
/** \* Add scrolling Events */
addScroll(): void {
window.addEventListener("scroll", this.watchScroll, true);
}
/** \* Remove scrolling events */
removeScroll(): void {
window.removeEventListener("scroll", this.watchScroll, true);
}
// Scroll paging , Screen scrolling event callback
watchScroll(): void {
// Scroll bar to the bottom and do not complete the search ( And more data )
if (this.isWindowBottom() && !this.pageFinished) {
++this.currentPage;
this.recieveRecommend();
}
}
// Scroll paging , Judge whether the current scroll bar has reached the bottom
public isWindowBottom(): boolean {
// When the scroll bar scrolls , Distance from the top
const scrollTop =
document.documentElement.scrollTop || document.body.scrollTop;
// The height of the viewing area , Numerically and “ Height of scroll bar rollers ” equal , Only the length unit is different
const windowHeight =
document.documentElement.clientHeight || document.body.clientHeight;
// The total height of the scroll bar
const scrollHeight =
document.documentElement.scrollHeight - 100 ||
document.body.scrollHeight - 100;
return scrollTop + windowHeight >= scrollHeight;
}
边栏推荐
- The interviewer asked: this point of JS
- HCIA-R&S自用笔记(19)VLAN配置及实验、VLAN间路由
- HCIA-R&S自用笔记(20)VLAN综合实验、GVRP
- Interview: your most impressive bug, for example
- HCIA-R&S自用笔记(18)园区网架构基础、交换机工作原理、VLAN原理
- Product principles of non-financial decentralized application
- HCIA-R&S自用笔记(21)STP技术背景、STP基础和数据包结构、STP选举规则及案例
- 数据库全栈工程师(DevDBOps)低首付、高回报,先就业后付款
- Eureka基本使用
- [MySQL] CentOS 7.9 installation and use mysql-5.7.39 binary version
猜你喜欢

Is test development development development?

Eureka基本使用

比海豹便宜,造型炸裂空间大,20万左右真没对手?长安全新“王炸”这样选才划算

HCIA-R&S自用笔记(18)园区网架构基础、交换机工作原理、VLAN原理

Pyqt5 how to set pushbutton click event to obtain file address

Incremental secure file system SFS based on C language design

Do you know the common core types of magnetic ring inductors?

Why am I still writing articles on CSDN? A journey of accompanying learning.

实战项目:Boost搜索引擎

【MySQL】CentOS 7.9安装、使用MySQL-5.7.39二进制版
随机推荐
[postgresql]postgresqlg use generate_ Series() function completes statistics
CSRC: agree to the IPO registration of Chuanyin holding science and Technology Innovation Board
Application of workflow engine in vivo marketing automation | engine 03
Hcia-r & s self use notes (20) VLAN comprehensive experiment, GVRP
[hcip] OSPF relationship establishment
Counter attack dark horse: devdbops training, give you the best courses!
杰理下载器强制下载工具的使用介绍_AC695N696NAD14AD15全系列支持
Interview: your most impressive bug, for example
企业数据治理面临的六大挑战!
json格式化小工具--pyqt5实例
With a total investment of 10billion US dollars, Huahong Wuxi 12 inch wafer factory was officially put into operation
Boss; Can flick CDC Oracle finish reading the full amount of data, just like directly fetching data from the database
org.yaml.snakeyaml.scanner. ScannerException: mapping values are not allowed here in ‘reader‘, line
[Luogu] p2709 little B's inquiry
Write golang simple C2 remote control based on grpc
基本的SELECT语句
菜鸟网络面试【杭州多测师】【杭州多测师_王sir】
Professor Ashe, a Chinese scientist, made a positive response to the suspected fake Nature paper
逆袭黑马:数据库全栈工程师(DevDBOps)培训,把最好的课程送给您!
MySQL random paging to get non duplicate data