Locks/ Unlock scroll for <body /> or other component.
Using npm:
npm install --save use-scrollock
Using yarn:
yarn add use-scrollock
import * as React from "react";
import { useClipboard } from "use-scrollock";
const Example = () => {
const { scrollock, toggleScrollock } = useClipboard();
return <div style={{ height: "100vh", background: "purple" }}>hello</div>;
};
disableHorizontalScroll
- Disables horizontal scroll. Defaults totrue
.disableVerticalScroll
- Disables vertical scroll. Defaults totrue
.padScrollbarSpace
- Should the scroll bar space be preserved. Defaults tofalse
.ref
- Provide reference to a component other than body.
scrollock
- Incicates the current scrollock state.toggleScrollock(value: boolean)
- toggles the scrollock state, you can manually set the value too.
If you found this project useful, then please consider giving it a ⭐️ on Github and sharing it with your friends via social media.
If you have any suggestion for including a feature or if something doesn't work, feel free to open a Github issue for us to have a discussion on it.
MIT © fayeed
This hook is created using create-react-hook.