feat: 为首页新增板块添加 ScrollTrigger pin 滚动效果

 新增 pin 效果(板块固定,内容随滚动切换):

1. HomeTestimonials - 客户评价
   - 固定板块,滚动自动切换卡片
   - 每屏切换一张评价卡片

2. HomeTechStack - 技术栈
   - 固定板块,3D 球体自动旋转一圈
   - 滚动控制旋转进度

3. HomeProcess - 创意流程
   - 固定板块,横向滚动浏览所有步骤
   - 6 个步骤依次展示

4. HomeServices - 服务能力
   - 固定板块,逐张卡片聚焦展示
   - 聚焦卡片放大,其他缩小变暗
   - 所有卡片飞入归位后逐个聚焦

5. HomeAchievements - 数字成就
   - 固定板块,逐个成就项展示
   - 每个数字滚动计数动画触发

6. HomeUpdates - 最新动态
   - 固定板块,逐批展示卡片
   - 分批出现,每批 3 个卡片

🎯 效果:
- 滚动到板块时自动固定(pin)
- 内部元素随滚动依次展示
- 所有内部元素展示完毕后才继续下一个板块
- 每个板块独特的 pin 动画效果

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
陈春
2026-06-03 19:49:18 +08:00
parent 89c4c4c7b5
commit bb0020b406
6 changed files with 208 additions and 76 deletions
+33 -22
View File
@@ -206,32 +206,43 @@ onMounted(async () => {
const cleanupParticles = initParticles()
ctx = gsap.context(() => {
// Pin 效果:固定板块,逐个成就项展示
const totalItems = achievements.length
const timeline = gsap.timeline()
// 初始隐藏所有
achievementElements.value.forEach((item, index) => {
if (!item) return
gsap.set(item, { autoAlpha: 0, x: index % 2 === 0 ? -100 : 100 })
})
// 成就项入场动画
gsap.fromTo(item,
{ autoAlpha: 0, x: index % 2 === 0 ? -100 : 100 },
{
scrollTrigger: {
trigger: item,
start: 'top 80%',
toggleActions: 'play none none reverse',
onEnter: () => {
// 触发数字计数
const numberEl = numberElements.value[index]
if (numberEl) {
animateNumber(numberEl, achievements[index].number, achievements[index].suffix)
}
}
},
autoAlpha: 1,
x: 0,
duration: 1,
delay: index * 0.2,
ease: 'power3.out'
// 逐个展示每个成就项
for (let i = 0; i < totalItems; i++) {
timeline.addLabel(`item-${i}`)
timeline.to(achievementElements.value[i], {
autoAlpha: 1,
x: 0,
duration: 0.8,
ease: 'power3.out',
onStart: () => {
// 触发数字计数
const numberEl = numberElements.value[i]
if (numberEl) {
animateNumber(numberEl, achievements[i].number, achievements[i].suffix)
}
}
)
}, `item-${i}`)
}
ScrollTrigger.create({
trigger: rootRef.value,
start: 'top top',
end: () => `+=${totalItems * window.innerHeight}`,
pin: true,
scrub: true,
anticipatePin: 1,
animation: timeline,
})
}, rootRef.value)