fix: 修复所有首页板块 pin 滚动不连贯问题
🐛 问题根源: 每个板块有两套独立的 ScrollTrigger 在同一个元素上: - 入场动画用独立的 scrollTrigger - pin 效果用 ScrollTrigger.create 两者互相冲突,导致空白间隙和动画跳变 ✅ 修复方案: 将所有板块的入场动画和 pin 滚动合并为一个统一时间线(timeline), 确保动画从 pin 开始到结束完全连续,无空白区 🔧 修复的 6 个板块: 1. HomeTestimonials - 标题入场 + 卡片逐张切换(淡入淡出) 2. HomeServices - 标题入场 + 卡片飞入归位 + 逐张聚焦 3. HomeAchievements - 逐个成就项展示(前一个淡出,后一个淡入) 4. HomeTechStack - 内容入场 + 标签散开 + 球体旋转 5. HomeProcess - 标题入场 + 线条绘制 + 步骤逐个出现 + 横向滚动 6. HomeUpdates - 标题入场 + 卡片分批出现 🎯 效果: - pin 期间动画完全连续,无空白间隙 - 入场和 pin 共享同一个 timeline - scrub: 0.5 让滚动更平滑 - 每个板块到下一个板块无缝过渡 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -193,61 +193,38 @@ onMounted(async () => {
|
||||
if (!rootRef.value || !contentRef.value) return
|
||||
|
||||
ctx = gsap.context(() => {
|
||||
// 右侧内容动画
|
||||
gsap.fromTo(contentRef.value,
|
||||
{ autoAlpha: 0, x: 100 },
|
||||
{
|
||||
scrollTrigger: {
|
||||
trigger: contentRef.value,
|
||||
start: 'top 80%',
|
||||
toggleActions: 'play none none reverse'
|
||||
},
|
||||
autoAlpha: 1,
|
||||
x: 0,
|
||||
duration: 1,
|
||||
ease: 'power3.out'
|
||||
}
|
||||
)
|
||||
// 初始状态
|
||||
gsap.set(contentRef.value, { autoAlpha: 0, x: 100 })
|
||||
techElements.value.forEach((el) => {
|
||||
if (!el) return
|
||||
gsap.set(el, { autoAlpha: 0, scale: 0 })
|
||||
})
|
||||
|
||||
// 技术标签从中心爆炸散开
|
||||
// 统一时间线:入场 + pin 旋转
|
||||
const tl = gsap.timeline()
|
||||
|
||||
// 第一屏:内容入场 + 技术标签散开
|
||||
tl.to(contentRef.value, { autoAlpha: 1, x: 0, duration: 0.8, ease: 'power3.out' }, 0)
|
||||
techElements.value.forEach((el, index) => {
|
||||
if (!el) return
|
||||
|
||||
gsap.fromTo(el,
|
||||
{ autoAlpha: 0, scale: 0 },
|
||||
{
|
||||
scrollTrigger: {
|
||||
trigger: sphereRef.value,
|
||||
start: 'top 75%',
|
||||
toggleActions: 'play none none reverse'
|
||||
},
|
||||
autoAlpha: 1,
|
||||
scale: 1,
|
||||
duration: 1,
|
||||
delay: index * 0.05,
|
||||
ease: 'back.out(2)'
|
||||
}
|
||||
)
|
||||
tl.to(el, {
|
||||
autoAlpha: 1, scale: 1, duration: 0.8, ease: 'back.out(2)',
|
||||
}, 0.3 + index * 0.05)
|
||||
})
|
||||
|
||||
// Pin 滚动效果:固定板块,球体旋转一圈展示所有技术
|
||||
const rotationTimeline = gsap.timeline()
|
||||
|
||||
rotationTimeline.to(autoRotation.value, {
|
||||
y: 360,
|
||||
duration: 3,
|
||||
ease: 'none',
|
||||
onUpdate: updatePositions
|
||||
})
|
||||
// 后续屏:球体旋转一圈
|
||||
tl.to(autoRotation.value, {
|
||||
y: 360, duration: 3, ease: 'none', onUpdate: updatePositions,
|
||||
}, 1.5)
|
||||
|
||||
ScrollTrigger.create({
|
||||
trigger: rootRef.value,
|
||||
start: 'top top',
|
||||
end: () => `+=${window.innerHeight * 2}`,
|
||||
end: () => `+=${window.innerHeight * 3}`,
|
||||
pin: true,
|
||||
scrub: 1,
|
||||
anticipatePin: 1,
|
||||
animation: rotationTimeline,
|
||||
animation: tl,
|
||||
})
|
||||
}, rootRef.value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user