diff --git a/app/pages/index.vue b/app/pages/index.vue index 5fe7d2b..998074a 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -54,7 +54,6 @@ const loaderRef = ref(null) const loaderBarRef = ref(null) const introRef = ref(null) const introTitleRef = ref(null) -const introCharRefs = ref([]) const heroStageRef = ref(null) const heroRef = ref(null) const heroPanelRef = ref(null) @@ -96,10 +95,11 @@ onMounted(() => { } const introCharElements = gsap.utils.toArray('.hero-intro-char', introElement) + const tmElement = introElement.querySelector('.hero-intro-tm') - if (introCharElements.length === 0) { - return - } + if (introCharElements.length === 0 || !tmElement) { + return + } const { $lenis } = useNuxtApp() as ReturnType & { $lenis?: Lenis } const topHeader = document.querySelector('.site-header-top') @@ -210,10 +210,10 @@ onMounted(() => { y: 0, autoAlpha: 1, }) - .set('.hero-intro-tm', { + .set(tmElement, { autoAlpha: 0, }) - .fromTo(gsap.utils.toArray('.hero-intro-char', introElement), { + .fromTo(introCharElements, { yPercent: 110, y: 0, }, { @@ -222,7 +222,7 @@ onMounted(() => { duration: 0.75, stagger: 0.055, }) - .to('.hero-intro-tm', { + .to(tmElement, { autoAlpha: 1, duration: 0.4, ease: 'power2.out', @@ -271,7 +271,7 @@ onMounted(() => { gsap.set(introTitleElement, { y: 0, autoAlpha: 1 }) // 强制清除 CSS 中的 translateY 像素值,避免被 GSAP 解析为固定 y 像素导致一直不可见 gsap.set(introCharElements, { y: 0, yPercent: 110 }) - gsap.set('.hero-intro-tm', { autoAlpha: 0 }) + gsap.set(tmElement, { autoAlpha: 0 }) gsap.set(heroElement, { yPercent: 100 }) if (topHeader) { gsap.set(topHeader, { yPercent: -140, autoAlpha: 0 }) @@ -336,7 +336,7 @@ onBeforeUnmount(() => { :data-demo-user="demoUserName" :data-demo-user-role="demoUserRole" > -