useScrollDirection
A Vue composable that tracks the scroll direction of the window (up, down, or null).
Installation
bash
npx kuro-ui add useScrollDirectionbash
npx github:Bartek-Nowak/Kuro add useScrollDirectionUsage
ts
import { useScrollDirection } from '@/composables/kuro/useScrollDirection'
const { direction } = useScrollDirection()Returns
| Name | Type | Description |
|---|---|---|
| direction | Ref<'up' | 'down' | null> | Reactive value representing the current scroll direction. |
Details
- The
directionis initiallynull. - When the user scrolls:
- It becomes
'down'if scrolling down, 'up'if scrolling up.
- It becomes
- The scroll listener is registered on component mount and removed on unmount to avoid memory leaks.