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). If the overflow property of the body is set to hidden, the body widens by the width of the scrollbar. This produces an unpleasant flickering effect, especially on websites with centered content. If the reserveScrollBarGap option is set, this gap is filled by a padding-right on the body element. If disableBodyScroll is called for the last target element, or clearAllBodyScrollLocks is called, the padding-right is automatically reset to the previous value. Works with vanilla JS and frameworks such as React / Angular / VueJS. Disables body scroll WITHOUT disabling scroll of a target element. Supports nested target elements (eg. a modal that appears on top of a flyout).

Features

  • Disables body scroll without disabling scroll of a target element
  • Works on iOS mobile/tablet
  • Works on Safari desktop
  • Works on Chrome/Firefox
  • Works with vanilla JS and frameworks such as React / Angular / VueJS
  • Supports nested target elements (eg. a modal that appears on top of a flyout)
  • Can reserve scrollbar width

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow BSL

BSL Web Site

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of BSL!

Additional Project Details

Operating Systems

Android, Apple iPhone

Programming Language

JavaScript

Related Categories

JavaScript User Interface (UI) Software

Registered

2022-03-04