jossmac / react-scrolllock

🔒 Prevent scroll on the <body />
https://jossmac.github.io/react-scrolllock
MIT License
450 stars 40 forks source link

On mobile, scrolling locked even within modal #82

Open dancherb opened 3 years ago

dancherb commented 3 years ago

When putting the element on my page in any form, the following errors call:

this.scrollableArea.addEventListener is not a function this.scrollableArea.removeEventListener is not a function

I'm using it as the docs suggest, in a modal component:

<div>
          <TouchScrollable>
                <View>
                            {p.children}
                 </View>
           /TouchScrollable>
</div>

What I'm trying to achieve: currently the scroll lock works great on standard web by just including when necessary on my root screen. As suggested by the docs, it's not playing well on mobile - even the modals become locked from touch scrolling.

Update: seems like the error only occurs when you use a custom child component (i.e. View) - div doesn't cause the error. However, touch scrolling is still locked in the modal when it shouldn't be (standard mouse scrolling in Chrome simulator, and on desktop browsers, still works fine).

dancherb commented 3 years ago

It seems like this isn't related to <ScrollLock/> - just putting any elements inside <TouchScrollable> prevents their scrolling on mobile, without a <ScrollLock/> anywhere in the document or project.

Lukavyi commented 3 years ago

I have the same issue

rick-liruixin commented 9 months ago

They stopped the repairs. I had to do it myself, in the same way, with a new version of typeScript. And fix these problems for everyone to use. add react hooks、vue3 example

npm i body-scroll-lock-upgrade

repair log,Refer to the releases page. @Lukavyi @dancherb