useScrollDetect: detects scroll event types: scroll derection (horizontal, vertical) and whether page-top or page-bottom or middle.
npm install --save use-scroll-detect
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
MIT © leewind99
-
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.
-
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.