Skip to content

rhabit/react-scrolllock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Scroll Lock

Prevent scroll on the <body /> when a component is mounted.

Install

yarn add react-scrolllock

Usage

import ScrollLock from 'react-scrolllock';

class Modal extends Component {
  render() {
    return (
      <div>
        ...
        <ScrollLock />
      </div>
    );
  }
}

Props

Property Description
accountForScrollbars boolean Default: true -- Measures the scrollbar width and replaces it with padding when mounted.
touchScrollTarget HTMLElement Default: null -- Touch scroll is locked for iOS when mounted due to overflow: hidden; not being observed on the <body/>. This property allows you to provide an element to allow scroll on, typically within a modal.

About

🔒 Prevent scroll on the <body /> when mounted

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%