jossmac / react-scrolllock

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

Replace inline styles on the body with an injected stylesheet #28

Closed jossmac closed 6 years ago

jossmac commented 6 years ago
jantimon commented 6 years ago

One issue might be that if Stylesheet is added 3 times it would only inject 1 <style> tag but if it is removed only once then it would still remove the <style> tag for all scroll locks

jossmac commented 6 years ago

@jantimon thanks for taking a look!

One tag is created by the first lock to mount -- a reference to that node is stored on the instance, so other locks don't have access to it. The behaviour then, will be that nothing changes until the last lock unmounts.

https://github.com/jossmac/react-scrolllock/pull/28/files#diff-ddf7339dc77298a220253f46c2dc6591R33


Edit: just loaded up a bunch at once, then removed -- all good 🎉