jossmac/react-scrolllock
์๊ฐ
๐ <body />์ ์คํฌ๋กค์ ๋ฐฉ์งํฉ๋๋ค.
์น ๋ฐ ์ฑ ๊ฐ๋ฐ์ธก์ ๋ ์คํ ์ฆ๊ฐ
- in 24h
- 0
- in 7 days
- +5
- in 15 days
- +5
- in 1 month
- ๊ธฐ๋ก ์์ง ์ค
์๋ก ๊ฒน์น๋ ๊ธฐ๊ฐ์ ์์ฆ๊ฐ๋์ด๋ฉฐ ์ผ๋ณ ํฉ๊ณ๊ฐ ์๋๋๋ค. ์ธก์ ๊ฐ์ด ์์ผ๋ฉด ๋น์ ๋ก๋๋ค. ์คํ๋ ๊ด์ฌ๋๋ฅผ ๋ํ๋ด๋ฉฐ ํ์ง์ ๋ณด์ฅํ์ง ์์ต๋๋ค.
README.md
Original๐จ Not Maintained
This was a great project to learn from and fulfilled the requirements it set out to. Unfortunately, I can no-longer give this project the time it needs. Consider body-scroll-lock as an alternative.
React Scroll Lock
Prevent scroll on the <body /> when a component is mounted.
Install
yarn add react-scrolllock
Usage
import ScrollLock, { TouchScrollable } from 'react-scrolllock';
class Modal extends Component {
state = { lockScroll: false }
render() {
return (
<div>
...
// the lock accepts a single child element, which supports touch-scrolling.
<ScrollLock>
<ElementWithScrollableContent>...</ElementWithScrollableContent>
</ScrollLock>
// if your app structure doesn't allow wrapping like above, the `TouchScrollable`
// component is exposed as a named export.
<ScrollLock />
<TouchScrollable>
<ElementWithScrollableContent>...</ElementWithScrollableContent>
</TouchScrollable>
// you can also toggle the lock based on some state.
<ScrollLock isActive={this.state.lockScroll} />
</div>
);
}
}
Props
ScrollLock
| Property | Description |
|---|---|
accountForScrollbars boolean |
Default: true -- Whether or not to replace the scrollbar width when active. |
isActive boolean |
Default: true -- Whether or not the lock is active. |
children element |
Default: null -- This element is wrapped internally by the TouchScrollable component. |
TouchScrollable
Wrap an element in the TouchScrollable component if you need an area that supports scroll on mobile.
This is necessary because the touchmove event is explicitly cancelled โ iOS doesn't observe overflow: hidden; when applied to the <body /> element ๐ข
| Property | Description |
|---|---|
children element |
ref => element |
๊ด๋ จ ํ๋ก์ ํธ ์ดํด๋ณด๊ธฐ
๋ถ๋ฌ์ค๋ ์คโฆ