src/hooks/use-offset-top.tsximport { useEffect } from 'react'import { state } from '@/state'// ----------------------------------------------------------------------export default function useOffsetTop(top?: number) {const isTop = top || 100useEffect(() => {const onScroll = () => {state.lastScrollingDirection = state.scrollingDirectionstate.lastOffsetTop = state.offsetTopstate.offsetTop = window.scrollYif (!state.lockScrollDirection) {if (state.offsetTop > state.lastOffsetTop) {state.scrollingDirection = 'down'} else if (state.offsetTop < state.lastOffsetTop) {state.scrollingDirection = 'up'} else {state.scrollingDirection = 'none'
Showing the first 20 lines.
Get full code