0.1.1 • Published 4 years ago
@ashalfarhan/use-scroll-react v0.1.1
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 --saveDocs
const { scrolling, scrollBottom, scrollTop } = useScroll();scrolling
Return
booleanDetect scrolling to bottom event
scrollBottom
Return
booleanSame as
scrollingscrollTop
Return
booleanDetect 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