feat: lock scroll at hero 100% — prevent scrolling past hero
This commit is contained in:
@@ -103,28 +103,33 @@ export default function CloudRevealSection() {
|
|||||||
|
|
||||||
useMotionValueEvent(scrollYProgress, 'change', (progress) => {
|
useMotionValueEvent(scrollYProgress, 'change', (progress) => {
|
||||||
if (!loaded) return
|
if (!loaded) return
|
||||||
|
|
||||||
// Frame güncelle
|
|
||||||
const frameIndex = Math.min(Math.floor(progress * (TOTAL_FRAMES - 1)), TOTAL_FRAMES - 1)
|
const frameIndex = Math.min(Math.floor(progress * (TOTAL_FRAMES - 1)), TOTAL_FRAMES - 1)
|
||||||
if (frameIndex !== currentFrameRef.current) {
|
if (frameIndex !== currentFrameRef.current) {
|
||||||
currentFrameRef.current = frameIndex
|
currentFrameRef.current = frameIndex
|
||||||
drawFrame(frameIndex)
|
drawFrame(frameIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
// %100'de bir sonraki bölüme snap et
|
|
||||||
if (progress >= 0.99 && !hasSnapped.current) {
|
|
||||||
hasSnapped.current = true
|
|
||||||
const next = document.getElementById('proje')
|
|
||||||
if (next) {
|
|
||||||
next.scrollIntoView({ behavior: 'smooth' })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Geri scroll yapılırsa snap'i sıfırla
|
|
||||||
if (progress < 0.9) {
|
|
||||||
hasSnapped.current = false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// %100'de aşağı scroll'u kilitle
|
||||||
|
useEffect(() => {
|
||||||
|
const onWheel = (e: WheelEvent) => {
|
||||||
|
if (scrollYProgress.get() >= 0.99 && e.deltaY > 0) {
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const onTouchMove = (e: TouchEvent) => {
|
||||||
|
if (scrollYProgress.get() >= 0.99) {
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.addEventListener('wheel', onWheel, { passive: false })
|
||||||
|
window.addEventListener('touchmove', onTouchMove, { passive: false })
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('wheel', onWheel)
|
||||||
|
window.removeEventListener('touchmove', onTouchMove)
|
||||||
|
}
|
||||||
|
}, [scrollYProgress])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const canvas = canvasRef.current
|
const canvas = canvasRef.current
|
||||||
if (!canvas) return
|
if (!canvas) return
|
||||||
|
|||||||
Reference in New Issue
Block a user