使用案例
与gsap结合
import { gsap } from 'gsap';
import Lenis from '@studio-freight/lenis';
const lenis = new Lenis();
// 初始化 GSAP 动画
gsap.to('.box', {
x: 500,
scrollTrigger: {
trigger: '.box',
start: 'top center',
end: 'bottom center',
scrub: true,
onUpdate: (self) => {
console.log('动画进度:', self.progress);
},
},
});
// 绑定 Lenis 与 GSAP
lenis.on('scroll', () => {
ScrollTrigger.update();
});