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 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)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user