1.0.0 • Published 2 years ago

use-scroll-detect v1.0.0

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

lee-wind-dev/use-scroll-detect

What is this ?

useScrollDetect: detects scroll event types: scroll derection (horizontal, vertical) and whether page-top or page-bottom or middle.

NPM JavaScript Style Guide

Install

npm install --save use-scroll-detect

Usage

import * as React from 'react'

import { useScrollDetect } from 'use-scroll-detect'

const App = () => {
  const derection = useScrollDetect({})
  console.log('derection', derection)

  return (
    <>
      <div style={{ width: '3000px', height: '3000px' }}></div>
    </>
  )
}

export default App

License

MIT © leewind99

Options

  • useScrollDetect() handle and show all detect scroll.
  • useScrollDetect(true,) detect scroll change based on axis X.
  • useScrollDetect(,true) detect scroll change based on axis Y.

Developing

  • useScrollDetect.isPageTop() whether at the page top or not.
  • useScrollDetect.isPageBottom() whether at the page bottom or not.
  • useScrollDetect.getPxToTop() will return scrollTop amount in pixels.

use-scroll-detect