Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
react-scrolllock
Advanced tools
Readme
Prevent scroll on the <body />
when a component is mounted.
yarn add react-scrolllock
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>
);
}
}
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. |
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 |
FAQs
Prevent scroll on the body when component is mounted.
The npm package react-scrolllock receives a total of 89,142 weekly downloads. As such, react-scrolllock popularity was classified as popular.
We found that react-scrolllock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.