Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable iOS Overscroll but allow body scrolling

I would like to disable the iOS overscroll in a webapp but still allow the body to be scrolled.

$(document).on('touchmove', function(e) {
    e.preventDefault();
});

disables scrolling altogether (as one would expect).

Is there a way to do what I want to do?

like image 909
Michael Bates Avatar asked May 11 '12 06:05

Michael Bates


2 Answers

I had pretty much the same issue. This should help you:

// Disable overscroll / viewport moving on everything but scrollable divs
 $('body').on('touchmove', function (e) {
         if (!$('.scrollable').has($(e.target)).length) e.preventDefault();
 });
like image 138
Jeff Avatar answered Sep 18 '22 10:09

Jeff


document.body.addEventListener('touchmove',function(e){
     if(!$(e.target).hasClass("scrollable")) {
       e.preventDefault();
     }
 });

Try this i just got in via google

like image 20
Okky Avatar answered Sep 18 '22 10:09

Okky