60
GitHub - jossmac/react-scrolllock: ? Prevent scroll on the <body /> when m...
source link: https://github.com/jossmac/react-scrolllock
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
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 accountForScrollbarsboolean
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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK