应用场景: - 当用户滚动内部div时,一旦内部div到达末尾,它就不应该滚动外部div。
如果内部div已经到达末尾,那么以下代码可以完美地工作。也就是说,在内部div到达末尾后触发touchstart/touchmove事件。
但是,如果我不停止触摸并继续滚动,并且此过程中内部div的末尾到达了,它就开始滚动外部div。
$('body').find('.scrollableDiv').on(
{
'touchstart' : function(e) {
touchStartEvent = e;
},
'touchmove' : function(e) {
e.stopImmediatePropagation();
$this = $(this);
if ((e.originalEvent.touches[0].pageY > touchStartEvent.originalEvent.touches[0].pageY && this.scrollTop == 0) ||
(e.originalEvent.touches[0].pageY < touchStartEvent.originalEvent.touches[0].pageY && this.scrollTop + this.offsetHeight >= this.scrollHeight)){
e.preventDefault();
}
},
});
如何在内部div到达末尾时立即停止滚动? 我正在尝试在Android设备的浏览器上实现此目标。 能否有人在这方面帮助我?
注意:用户甚至应该能够滚动外部div。
提前致谢。