fix. 불필요한 코드 정리
This commit is contained in:
34
app/app.vue
34
app/app.vue
@@ -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>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user