View the demo
Prevent page scrolling like a boss.
Supports scroll, wheel, touchmove, keydown events.
npm install --save disable-scrolland import it
import disableScroll from 'disable-scroll';disableScroll.on(); // prevent scrolling
...
disableScroll.off(); // re-enable scrollDisable page scroll by adding event listeners and locking the scroll position.
[element]- DOM Element. Defaults todocument.scrollingElement[options]- Change the initial options. Defaults to:
{
disableWheel: true,
disableScroll: true,
disableKeys: true,
keyboardKeys: [32, 33, 34, 35, 36, 37, 38, 39, 40]
}Re-enable page scrolling and remove the listeners.
Inspired by jquery-disablescroll