streamich / react-use

React Hooks — 👍
http://streamich.github.io/react-use
The Unlicense
41.56k stars 3.13k forks source link

Clarification on useLockBodyScroll #1016

Open zslabs opened 4 years ago

zslabs commented 4 years ago

Hi, Could I some clarification on https://github.com/streamich/react-use/blob/master/docs/useLockBodyScroll.md and its intent? The description mentions locking down the body element, but what I'm looking for it to do would be for locking the "background" body element, while preserving scrolling within things like a modal or offcanvas menu. Right now, when using this as part of https://github.com/gremlin/chaoskit/blob/feature/emotion/src/components/OffCanvas.js (main repo) scrolling on touch devices is locked within the overlay panels.

Tagging @andrico1234 for iOS changes.

kjbrum commented 4 years ago

I'm running into this issue as well with a mobile navigation. The body locks correctly while the menu is open, but I'm unable to scroll the overflow content inside of the overlay.

bjonamu commented 4 years ago

I was facing the same issue I ended up using https://www.npmjs.com/package/body-scroll-lock

zslabs commented 4 years ago

Thanks for the tip @bjonamu that's working great!

Tarpsvo commented 3 years ago

Same question here. I assumed the hook and the package linked here did the same thing, but apparently not.