negomi / react-burger-menu

:hamburger: An off-canvas sidebar component with a collection of effects and styles using CSS transitions and SVG path animations
http://negomi.github.io/react-burger-menu/
MIT License
5.05k stars 586 forks source link

Possible to have relatively positioned menu toggle but disable scrolling on opening menu? #391

Closed davidrhoderick closed 4 years ago

davidrhoderick commented 4 years ago

As opposed to another confusingly titled issue, I'd actually like a relatively positioned menu toggle that cancels scrolling on opening the menu. I've tried what the wiki states and it hasn't worked yet, plus, I realized that the toggle button becomes fixed when I apply the wiki's styles.

Here is the demo site and repository:

It uses a scroll-to-top button instead of a fixed react-burger-menu.

davidrhoderick commented 4 years ago

This would be great to have built into this component but who knows how many use-cases there are (perhaps it's just me and a couple others).

Therefore, I was able to use disable-scroll and the onClose and onOpen handlers (along with a useEffect hook to allow scrolling on load) to get this working.