Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

disable-scroll

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disable-scroll

Prevent page scroll

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

disable scroll

NPM version build status Maintainability Test Coverage

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

If you need to support legacy browsers you need to include the scrollingelement polyfill.

API

.on(element?: Element, options?: Options)

Disable page scroll by adding event listeners and locking the scroll position.

Options defaults to:

{
    authorizedInInputs: [32, 37, 38, 39, 40],
    disableKeys: true,
    disableScroll: true,
    disableWheel: true,
    keyboardKeys: [32, 33, 34, 35, 36, 37, 38, 39, 40],
}

.off()

Re-enable page scrolling and remove the listeners.

Issues

If you find a bug, please file an issue on our issue tracker on GitHub.

License

MIT


Inspired by jquery-disablescroll

Keywords

FAQs

Package last updated on 04 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc