refactor: 移除新增板块的 ScrollTrigger pin 效果
从 HomeServices 开始往后的 6 个板块, 去掉 pin(固定)和 scrub(滚动驱动)效果, 改为正常的入场动画:滚动到时触发动画,播放完毕后正常滚动 修改的板块: - HomeServices: 卡片飞入归位(无 pin) - HomeAchievements: 逐个数字展示(无 pin) - HomeTestimonials: 卡片扩散入场(无 pin) - HomeTechStack: 标签散开入场(无 pin) - HomeProcess: 标题 + 线条 + 步骤入场(无 pin) - HomeUpdates: 卡片错开入场(无 pin) 保留 HomePartnersWork 的 pin 效果(原有板块) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -171,39 +171,23 @@ onMounted(async () => {
|
||||
gsap.set(card, { autoAlpha: 0, y: 60, scale: 0.9 })
|
||||
})
|
||||
|
||||
// 统一时间线:无空白
|
||||
// 入场动画(无 pin):标题 + 卡片错开出现
|
||||
const tl = gsap.timeline()
|
||||
let cursor = 0
|
||||
|
||||
// 第一屏:标题入场
|
||||
tl.to(headerRef.value, { autoAlpha: 1, y: 0, duration: 0.8, ease: 'power3.out' }, cursor)
|
||||
cursor += 1
|
||||
tl.to(headerRef.value, { autoAlpha: 1, y: 0, duration: 0.8, ease: 'power3.out' }, 0)
|
||||
|
||||
// 分批展示卡片:每批 2 个,逐批出现
|
||||
const totalCards = updates.length
|
||||
const batchSize = 2
|
||||
const batches = Math.ceil(totalCards / batchSize)
|
||||
|
||||
for (let batch = 0; batch < batches; batch++) {
|
||||
const start = batch * batchSize
|
||||
const end = Math.min(start + batchSize, totalCards)
|
||||
|
||||
for (let i = start; i < end; i++) {
|
||||
tl.to(cardElements.value[i], {
|
||||
autoAlpha: 1, y: 0, scale: 1,
|
||||
duration: 0.7, ease: 'power3.out',
|
||||
}, cursor + (i - start) * 0.12)
|
||||
}
|
||||
cursor += 1
|
||||
}
|
||||
cardElements.value.forEach((card, index) => {
|
||||
if (!card) return
|
||||
tl.to(card, {
|
||||
autoAlpha: 1, y: 0, scale: 1,
|
||||
duration: 0.7, ease: 'power3.out',
|
||||
}, 0.3 + index * 0.1)
|
||||
})
|
||||
|
||||
ScrollTrigger.create({
|
||||
trigger: rootRef.value,
|
||||
start: 'top top',
|
||||
end: () => `+=${cursor * window.innerHeight}`,
|
||||
pin: true,
|
||||
scrub: 0.5,
|
||||
anticipatePin: 1,
|
||||
start: 'top 75%',
|
||||
toggleActions: 'play none none none',
|
||||
animation: tl,
|
||||
})
|
||||
}, rootRef.value)
|
||||
|
||||
Reference in New Issue
Block a user