let middle = document.getElementById('middle')
middle.addEventListener('scroll', (e)=> {
let before = middle.scrollTop
// 函数防抖
if (this.timer) {
clearTimeout(this.timer)
}
// 300ms后判定为滑动结束
this.timer = setTimeout(() => {
// 滑动结束
let after = middle.scrollTop
if(before == after) {
console.log('滚动位置确定了', middle.scrollTop);
}
}, 300)
});
相关文章
- 12-09移动端 记录滚动位置
- 12-09【移动端】确定滚动位置与是否结束滚动