javascript - 检测过度滚动的结束
<p><p>当元素的 <code>webkit-overflow-scrolling</code> 设置为“touch”(iOS 设备上 <code>document.documentElement</code> 的默认设置)时,用户可以过度滚动内容。当用户释放 <code>touchevent</code> 时,元素滚动到 0 需要一些时间。</p>
<p>如何检测过度滚动的结束?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>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');
}
});
</code></pre></p>
<p style="font-size: 20px;">关于javascript - 检测过度滚动的结束,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/27335320/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/27335320/
</a>
</p>
页:
[1]