disable-scroll
v0.5.0
Published
Prevent page scroll
Downloads
13,657
Readme
disable scroll
Prevent page scrolling like a boss.
Supports scroll, wheel, touchmove, keydown
events.
Setup
npm
npm install --save disable-scroll
and import it
import disableScroll from 'disable-scroll';
Usage
disableScroll.on(); // prevent scrolling
...
disableScroll.off(); // re-enable scroll
API
.on(element, options)
Disable 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]
}
.off()
Re-enable page scrolling and remove the listeners.
Inspired by jquery-disablescroll