From 43367aa17c78055765550d0211f7da6426d33da6 Mon Sep 17 00:00:00 2001 From: clkim Date: Tue, 17 Mar 2026 11:51:02 +0900 Subject: [PATCH] =?UTF-8?q?fix.=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app.vue | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/app/app.vue b/app/app.vue index 12bef91..c98a649 100644 --- a/app/app.vue +++ b/app/app.vue @@ -132,16 +132,22 @@ if (import.meta.server) { } let rafId: number | null = null -let stopWatch: (() => void) | null = null onMounted(() => { 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, newValue => { - if (rafId) { - cancelAnimationFrame(rafId) - } + if (rafId) cancelAnimationFrame(rafId) + rafId = requestAnimationFrame(() => { document.documentElement.style.setProperty( '--scroll-stove-position', @@ -152,27 +158,11 @@ onMounted(() => { }, { immediate: true } ) - - const { gtag, initialize } = useGtag() - initialize(gaCode.value) - gtag('event', 'screen_view', { - app_name: 'My App', - screen_name: 'Home', - }) }) onBeforeUnmount(() => { - // watch 정리 - if (stopWatch) { - stopWatch() - stopWatch = null - } - // requestAnimationFrame 정리 - if (rafId) { - cancelAnimationFrame(rafId) - rafId = null - } + if (rafId) cancelAnimationFrame(rafId) })