Socket
Socket
Sign inDemoInstall

no-scroll

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    no-scroll

Disable the document's scrolling


Version published
Weekly downloads
94K
decreased by-5.88%
Maintainers
1
Install size
5.88 kB
Created
Weekly downloads
 

Changelog

Source

2.1.1

  • Prevent accidentally scrolling to the top of the viewport if you call noScroll.on() twice without any intervening noScroll.off().

Readme

Source

no-scroll

Disable the document's scrolling.

It's silly how many libraries have their own implementation of this. So I thought I'd make a module that other libraries could use.

Here's how this works:

  • When you turn it on(), the documentElement is styled with width: calc(100% - scrollbarSize), position: fixed, top: currentScrollTop, and overflow: hidden.
  • When you turn it off(), everything goes back to the way it was before.

Installation

npm install no-scroll

Dependencies: none.

Browser Support

IE9+

Usage

This module exposes three simple functions: on(), off() and toggle().

var noScroll = require('no-scroll');

// To turn off the document's scrolling
noScroll.on();

// To restore scrolling
noScroll.off();

// To toggle scrolling
noScroll.toggle();

If you do not have a CommonJS environment (no module.exports), the module exposes the global object noScroll.

Keywords

FAQs

Last updated on 08 May 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc