Skip to content

sheeep/disable-scroll

 
 

Repository files navigation

disable scroll

NPM version build status Maintainability Test Coverage

View the demo

Prevent page scrolling like a boss.
Supports scroll, wheel, touchmove, keydown events.

Demo

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 to document.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

About

Prevent page scrolling

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%