diff --git a/app/app.vue b/app/app.vue index 3df3aa1..abe7abf 100644 --- a/app/app.vue +++ b/app/app.vue @@ -16,6 +16,7 @@ const scrollStore = useScrollStore() const { setGameData } = gameDataStore const { gameData } = storeToRefs(gameDataStore) const { youtube, confirm, alert, toast, handleResetYoutube } = modalStore +const { scrollGnbPosition } = storeToRefs(scrollStore) const metaData = ref(null) @@ -51,13 +52,22 @@ const setupAllMetaData = (data: GameDataValue) => { ] // 색상 CSS 변수 생성 - const cssVariables = Object.entries(data.key_color_json ?? {}) + const cssColorVariables = Object.entries(data.key_color_json ?? {}) .map(([key, value]) => `--${key}: ${value};`) - .join('\n ') + .join('\n ') + + const commImgVariables = + data.comm_img_json?.groups + ?.map( + ({ img_name, img_path }) => + `--${img_name}: url(${getImageHost(img_path?.comm ?? '')});` + ) + .join('\n ') ?? '' const cssContent = ` :root { - ${cssVariables} + ${cssColorVariables} + ${commImgVariables} } ` @@ -81,7 +91,7 @@ const setupAllMetaData = (data: GameDataValue) => { style: [ { innerHTML: cssContent, - id: 'game-color-variables', + id: 'game-css-variables', }, ], }) @@ -109,21 +119,34 @@ gtag('event', 'screen_view', { screen_name: 'Home', }) +let rafId: number | null = null + onMounted(() => { useEventListener('scroll', scrollStore.updateScrollValue) - if (gameData.value?.comm_img_json?.groups) { - const groups = gameData.value.comm_img_json.groups - groups.forEach(({ img_name, img_path }) => { - document.documentElement.style.setProperty( - `--${img_name}`, - `url(${getImageHost(img_path?.comm ?? '')})` - ) - }) - } + + watch( + scrollGnbPosition, + newValue => { + if (rafId) { + cancelAnimationFrame(rafId) + } + rafId = requestAnimationFrame(() => { + document.documentElement.style.setProperty( + '--scroll-position', + `${newValue}px` + ) + rafId = null + }) + }, + { immediate: true } + ) }) onBeforeUnmount(() => { removeEventListener('scroll', scrollStore.updateScrollValue) + if (rafId) { + cancelAnimationFrame(rafId) + } }) @@ -160,10 +183,7 @@ onBeforeUnmount(() => { :modal-name="alert.storeModalName" @confirm-button-event="alert.storeConfirmButtonEvent" /> - + diff --git a/layers/components/blocks/StoveGnbNew.vue b/layers/components/blocks/StoveGnbNew.vue index 88c26d8..2811706 100644 --- a/layers/components/blocks/StoveGnbNew.vue +++ b/layers/components/blocks/StoveGnbNew.vue @@ -46,10 +46,12 @@ onMounted(() => { mini: true, layout: 'wide', fixed: false, - } + }, } - mountedInstance = (window as any).StoveGnb.mount('#stove-wrap', stoveGnbOptions) - + mountedInstance = (window as any).StoveGnb.mount( + '#stove-wrap', + stoveGnbOptions + ) } }) @@ -61,22 +63,17 @@ onBeforeUnmount(() => { }) diff --git a/layers/components/blocks/modal/Toast.vue b/layers/components/blocks/modal/Toast.vue index 5ea708e..3663e1e 100644 --- a/layers/components/blocks/modal/Toast.vue +++ b/layers/components/blocks/modal/Toast.vue @@ -1,39 +1,13 @@