0.1.3 • Published 4 years ago

@ashalfarhan/use-scroll-react v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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
0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago