0.1.3 • Published 4 years ago
@ashalfarhan/use-scroll-react v0.1.3
React hooks useScroll
Description
This package is to detect scroll event
Installation
yarn add @ashalfarhan/use-scroll-react
#or
npm install @ashalfarhan/use-scroll-react --save
Docs
const { scrolling, scrollBottom, scrollTop } = useScroll();
scrolling
Return
boolean
Detect scrolling to bottom event
scrollBottom
Return
boolean
Same as
scrolling
scrollTop
Return
boolean
Detect scrolling to top event
Usage
import useScroll from '@ashalfarhan/use-scroll-react';
const MyComponent = () => {
const { scrolling, scrollBottom, scrollTop } = useScroll();
return (
<div style={{ minHeight: '200vh' }}>
<header style={{ display: scrolling ? 'none' : 'block' }}>
My Header
</header>
</div>
);
};
export default MyComponent;
Compatibility
- SSG
- CSR
- SSR