jossmac / react-scrolllock

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

Replace react-prop-toggle with a class #24

Closed jantimon closed 6 years ago

jantimon commented 6 years ago

I have a simple idea to reduce the code size and improve maintainability:

const bodyStyle = document.createElement("style");
document.head.appendChild(style);
style.sheet.insertRule('body.react-scrolllock { overflow:  hidden !important }');

This way you wouldn't have to track the original styles of the body element and you could just toggle the class and/or remove the stylesheet from document.
Also a new maintainer/developer would find out the source of overflow hidden.

theKashey commented 6 years ago

This will also resolve #17

jossmac commented 6 years ago

Sounds great @jantimon!

Could you submit a PR?

jossmac commented 6 years ago

@jantimon @theKashey could you take a look at #28?