当元素的 webkit-overflow-scrolling
设置为“touch”(iOS 设备上 document.documentElement
的默认设置)时,用户可以过度滚动内容。当用户释放 touchevent
时,元素滚动到 0 需要一些时间。
如何检测过度滚动的结束?
var overscroll;
window.addEventListener('touchstart', function () {
// User has very quick fingers.
overscroll = false;
});
window.addEventListener('touchend', function () {
// User released touch-drag event when element was in an overscroll state.
if (document.body.scrollTop < 0) {
overscroll = true;
}
});
window.addEventListener('scroll', function () {
if (overscroll && document.body.scrollTop == 0) {
overscroll = false;
console.log('end of overscroll');
}
});
关于javascript - 检测过度滚动的结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27335320/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |