chore: add animation on header

This commit is contained in:
2025-12-05 17:36:33 +01:00
parent 237e44624a
commit fb9d5ba632
6 changed files with 103 additions and 10 deletions

View File

@@ -0,0 +1,24 @@
export const useScroll = (threshold: number = 100) => {
const isScrolled = ref(false)
let rafId: number | null = null
const handleScroll = () => {
if(rafId) return
rafId = requestAnimationFrame(() => {
isScrolled.value = window.scrollY > threshold
rafId = null
})
}
onMounted(() => {
window.addEventListener('scroll', handleScroll)
handleScroll()
})
onUnmounted(() => {
window.removeEventListener('scroll', handleScroll)
})
return { isScrolled }
}