简化入场动画

This commit is contained in:
锦恢 2025-07-24 01:01:20 +08:00
parent 9fcc22b55a
commit 2c67ac5289

View File

@ -92,34 +92,17 @@
</svg>
</div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { gsap } from 'gsap'
const container = ref < any > (null);
const svgElement = ref < any > (null);
const container = ref<any>(null);
const svgElement = ref<any>(null);
onMounted(() => {
const paths = svgElement.value.querySelectorAll('path');
//
const nameClip = document.querySelector('.VPHero .heading .name.clip');
const headingText = document.querySelector('.VPHero .heading .text');
const tagline = document.querySelector('.VPHero .tagline');
const actions = document.querySelector('.VPHero .actions');
//
gsap.set(nameClip, {
transform: 'translate(50px, 80px)',
scale: 1.8,
});
gsap.set([headingText, tagline, actions], {
opacity: 0,
y: 20
});
// SVG
gsap.set(paths, {
strokeDasharray: (_, target) => {
const length = target.getTotalLength()
@ -160,16 +143,6 @@ onMounted(() => {
defaults: { duration: 1.5, ease: "power2.inOut" }
});
// OpenMCP
if (!nameClip || !headingText || !tagline || !actions) {
console.error("One or more required elements are missing.");
return;
}
drawTimeline.to(nameClip, {
transform: 'translate(50px, 80px)',
}, "<+=0.3");
// OpenMCP
paths.forEach((path: gsap.TweenTarget) => {
drawTimeline.to(path, {
@ -210,85 +183,21 @@ onMounted(() => {
}, "<")
});
// 线
const heroTimeline = gsap.timeline({
defaults: {
duration: 0.8,
ease: "power3.out"
}
});
//
heroTimeline
.to(nameClip, {
transform: 'translate(0, 0)',
scale: 1,
duration: 1.2,
ease: "back.out(1.7)"
})
.to([headingText, tagline, actions], {
opacity: 1,
y: 0,
stagger: 0.15,
duration: 0.6
}, "-=0.4"); // 0.4
// feature
const boxTimeline = gsap.timeline({
defaults: {
duration: 0.8,
ease: "power3.out"
}
});
// box
const boxes = document.querySelectorAll('.VPFeatures .item.grid-3');
//
gsap.set(boxes, {
opacity: 0,
y: 30,
scale: 0.9
});
// 线
boxTimeline.to(boxes, {
// SVG
gsap.set([
document.querySelector('.VPHero .heading .name.clip'),
document.querySelector('.VPHero .heading .text'),
document.querySelector('.VPHero .tagline'),
document.querySelector('.VPHero .actions'),
...document.querySelectorAll('.VPFeatures .item.grid-3')
], {
opacity: 1,
y: 0,
scale: 1,
stagger: 0.15,
onComplete: () => {
gsap.set(boxes, { clearProps: "all" });
}
scale: 1
});
// heroTimeline
heroTimeline
.to(nameClip, {
transform: 'translate(0, 0)',
scale: 1,
duration: 1.0, //
ease: "elastic.out(1, 0.5)" //
})
.to([headingText, tagline], {
opacity: 1,
y: 0,
stagger: 0.2, //
duration: 0.8,
ease: "back.out(1.5)" //
}, "-=0.3")
.to(actions, {
opacity: 1,
y: 0,
duration: 0.6,
ease: "power2.out" //
}, "-=0.2");
master.add(drawTimeline)
.add(reverseTimeline, "+=0.3") //
.add(heroTimeline, "-=0.3")
.add(boxTimeline, "<+=1.3")
.add(reverseTimeline, "+=0.3")
.add(wiggleTimeline, "<+=0.2");
})
</script>