当前位置:网站首页>Native JS --- infinite scrolling
Native JS --- infinite scrolling
2022-06-25 12:57:00 【Ziwei front end】
When you scroll down , Have you ever seen those automatic “ Load more ”? you are here Tumblr Have you seen any pictures on ? stay Gmail I've seen news on ? Still Facebook I saw... On ? cool , isn't it? ? Infinite scrolling is an alternative to paging , It's everywhere . It optimizes... According to user needs ( indirect ) User experience of loading data . You can get faster pages 、Web、 Application loading process , It only loads what you need , Instead of loading all . You don't need to add additional interactions 、 Button or widget , Because it has the normal reading behavior you are used to : Scroll down with the mouse or scroll on the touchable screen with your finger .
JS
const $ol = document.querySelector('ol')
function load_more() {
let html = ''
for (var i = 0; i < 5; i++) html += '<li></li>'
$ol.innerHTML += html
}
$ol.addEventListener('scroll', function() {
if ($ol.scrollHeight — $ol.scrollTop == $ol.clientHeight)
load_more()
})
边栏推荐
- MySQL adds, modifies, and deletes table fields, field data types, and lengths (with various actual case statements)
- Flutter automatically disappears after receiving push
- torch. Tensor splicing and list (tensors)
- Serevlt初识
- Drawing cubes with Visio
- JS picture switching (simple and practical)
- el-select clear 清空内容时触发事件
- 架构师必备的七种能力
- 使用Visio画立方体
- list. replace, str.append
猜你喜欢
随机推荐
Render values to corresponding text
[flask tutorial] flask overview
CUDA error: unspecified launch failure
Parse JSON format data and save it to entity class
剑指 Offer II 028. 展平多级双向链表
地理空间搜索:kd树的实现原理
Jupyter Notebook主题字体设置及自动代码补全
Serevlt初识
Capabilities required by architects
Resolved: could not find artifact XXX
Foreach method of array in JS
The editor is used every day. What is the working principle of language service protocol?
515. Find Largest Value in Each Tree Row
JSTL tag: fmt:formatdate tag format Chinese standard time or timestamp
地理空间搜索 ->R树索引
Qt鼠标跟踪
Shell learning notes (latest update: 2022-02-18)
字节跳动Dev Better技术沙龙来啦!参与活动赢好礼,限时免费报名中!
剑指 Offer II 025. 链表中的两数相加
WIN10环境下配置pytorch


![[flask tutorial] flask overview](/img/e8/d85ac54f3a9eb3b1ab31852761154c.jpg)






