fix. 불필요한 코드 정리

This commit is contained in:
clkim
2026-03-17 11:51:02 +09:00
parent 45796690ee
commit 43367aa17c

View File

@@ -132,16 +132,22 @@ if (import.meta.server) {
} }
let rafId: number | null = null let rafId: number | null = null
let stopWatch: (() => void) | null = null
onMounted(() => { onMounted(() => {
useEventListener('scroll', scrollStore.updateScrollValue, { passive: true }) useEventListener('scroll', scrollStore.updateScrollValue, { passive: true })
stopWatch = watch(
const { gtag, initialize } = useGtag()
initialize(gaCode.value)
gtag('event', 'screen_view', {
app_name: 'My App',
screen_name: 'Home',
})
watch(
scrollGnbPosition, scrollGnbPosition,
newValue => { newValue => {
if (rafId) { if (rafId) cancelAnimationFrame(rafId)
cancelAnimationFrame(rafId)
}
rafId = requestAnimationFrame(() => { rafId = requestAnimationFrame(() => {
document.documentElement.style.setProperty( document.documentElement.style.setProperty(
'--scroll-stove-position', '--scroll-stove-position',
@@ -152,27 +158,11 @@ onMounted(() => {
}, },
{ immediate: true } { immediate: true }
) )
const { gtag, initialize } = useGtag()
initialize(gaCode.value)
gtag('event', 'screen_view', {
app_name: 'My App',
screen_name: 'Home',
})
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
// watch 정리
if (stopWatch) {
stopWatch()
stopWatch = null
}
// requestAnimationFrame 정리 // requestAnimationFrame 정리
if (rafId) { if (rafId) cancelAnimationFrame(rafId)
cancelAnimationFrame(rafId)
rafId = null
}
}) })
</script> </script>