
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-scrolllock
Advanced tools
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 |
5.0.1
8adf1dc2
#69 Thanks @flexdinesh - Fix: consider body margin when calculating scrollbar widthFAQs
Prevent scroll on the body when component is mounted.
The npm package react-scrolllock receives a total of 82,280 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.