willmcpo / body-scroll-lock

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

Doesn't work correctly on iOS #184

Closed dreamofdark closed 4 years ago

dreamofdark commented 4 years ago

Content in targetElement doesn't scroll on mobile Safari

Sequoia commented 4 years ago

@dreamofdark Can you add more context here? What iOS device are you using? If possible, can you provide demo code?

(I ask because I am experiencing a hard-to-reproduce issue on an iPhone 11 that sounds similar to your issue.)

dreamofdark commented 4 years ago

This reproduces in safari in the xcode simulator on iphone or ipad with ios 13.3. I have modal window and content in this modal doesn't scroll Demo code: https://codesandbox.io/s/magical-vaughan-sy97z

Снимок экрана 2020-06-23 в 21 48 49
benekoehler commented 4 years ago

Hi, is there already a fix or workaround for this issue? I am too experiencing this issue. Thank you :)

diachedelic commented 4 years ago

@dreamofdark i changed your line

    const el = document.querySelector(".ReactModalPortal");

to

    const el = document.querySelector(".ReactModal__Content ReactModal__Content--after-open");

and it worked on my simulator running iOS 13.6 - make sure your targetElement is set to the element you actually want to scroll, not an ancestor thereof.