use-offset-top.tsx

src/hooks/use-offset-top.tsx
import { useEffect } from 'react'
import { state } from '@/state'
// ----------------------------------------------------------------------
export default function useOffsetTop(top?: number) {
const isTop = top || 100
useEffect(() => {
const onScroll = () => {
state.lastScrollingDirection = state.scrollingDirection
state.lastOffsetTop = state.offsetTop
state.offsetTop = window.scrollY
if (!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

Support

Talk to the developers of this project to learn more

We have been building professional websites for big clients for over 15 years. Gallop templates and blocks is our best foundation for SEO websites and web apps.

© 2026 Web Plant Media, LLC