4

I used to use the following code to prevent web page from scrolling on touch devices (specifically tested on iOS).

disableScroll = false;
$(document).on('touchmove',function(e) {
    if (disableScroll) {
        e.preventDefault();
    }
});

However since iOS 11 this no longer works. Using iOS Simulator I can go back and test on iOS 9 and iOS 10 and it works fine but no longer on iOS11. Can anyone suggest an alternative solution?

For example, testing this similar functionality on iOS 9/10 works but doesn't on iOS 11. https://benfrain.com/preventing-body-scroll-for-modals-in-ios/

Jesse
  • 3,522
  • 6
  • 25
  • 40
John the Painter
  • 2,495
  • 8
  • 59
  • 101

1 Answers1

1

Similar question but with plain javascript is answered at https://stackoverflow.com/a/49582193

document.addEventListener('touchmove', function(e) {
    e.preventDefault();
}, { passive: false });
Bati
  • 41
  • 6
  • you need to bind preventDefault to two events: touchmove && touchforcechange. https://bugs.webkit.org/show_bug.cgi?id=163207 – User007 Aug 18 '19 at 06:37