Use Case : - If the user is scrolling an inner div it should not scroll the outer div once inner div end has reached.
The following code works perfectly fine if the inner div has already reached the end. i.e the touchstart/touchmove event triggers after the inner div has reached the end.
But in case I do not lift the touch and keeps scrolling and if the end of the inner div has reached in this process, it starts scrolling the outer 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();
}
},
});
How do I stop scrolling as soon as the end of the inner div is reached? I am trying to achieve this on a browser on android device. Can someone help me in this regard?
NOTE : The user should even be able to scroll the outer div.
Thanks in advance.