willmcpo / body-scroll-lock

Body scroll locking that just works with everything 😏
MIT License
4.04k stars 337 forks source link

Disable Body Scroll Not Working iOS 12, 13 #149

Closed carltesta closed 4 years ago

carltesta commented 4 years ago

I'm using Body-Scroll-Lock in a simple webpage. I want to mimic the feel of an app on iOS but I cannot disable the momentum scrolling. The following works on Desktop (Chrome), but doesn't work on iOS safari. What am I missing? The "#main" element is the class of the body tag in the HTML.

diachedelic commented 4 years ago

window.onload expects to be assigned a function, you could try

window.onload = function() {
  bodyScrollLock.disableBodyScroll(targetElement);
}

instead

carltesta commented 4 years ago

Thanks, I tried this but then the body scroll lock doesn't work on either Desktop or mobile.

awhwebteam commented 4 years ago

I got 3 devices.

@diachedelic solution doesn't work as well.

smolnikov commented 4 years ago

@awhwebteam please provide the example of code you're using. https://output.jsbin.com/goxirebemi I checked this on iOS 13 and iOS 12 – it works fine.