Socket
Socket
Sign inDemoInstall

body-scroll-lock

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

body-scroll-lock

Enables body scroll locking (for iOS Mobile and Tablet, Android, desktop Safari/Chrome/Firefox) without breaking scrolling of a target element (eg. modal/lightbox/flyouts/nav-menus)


Version published
Weekly downloads
847K
increased by3.61%
Maintainers
1
Weekly downloads
 
Created

What is body-scroll-lock?

The body-scroll-lock package is designed to disable scrolling on the body element of a webpage, typically used when a modal or overlay is open to prevent background scrolling. It provides a simple API to lock and unlock scroll on touch and non-touch devices.

What are body-scroll-lock's main functionalities?

Disable scrolling on the body

This feature allows you to disable scrolling on the body of the page. The target element is typically the modal or overlay that is currently active.

import { disableBodyScroll } from 'body-scroll-lock';
const targetElement = document.querySelector('#someElementId');
disableBodyScroll(targetElement);

Enable scrolling on the body

This feature re-enables scrolling on the body of the page. It is used when the modal or overlay is closed and normal page interaction is to be restored.

import { enableBodyScroll } from 'body-scroll-lock';
const targetElement = document.querySelector('#someElementId');
enableBodyScroll(targetElement);

Clear all body scroll locks

This function clears all locks on body scroll. It is useful when you need to ensure that all locks have been removed, for instance, during cleanup or unmounting of components.

import { clearAllBodyScrollLocks } from 'body-scroll-lock';
clearAllBodyScrollLocks();

Other packages similar to body-scroll-lock

Keywords

FAQs

Package last updated on 23 Jun 2021

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