我正在使用 GSAP 和 ScrollTrigger 做一些滚动动画。我面临的问题是动画在页面加载时开始,而不是在我向下滚动到元素时开始。这是代码:
<script>
const leftEl = document.querySelector('.section-b .left');
const rightEl = document.querySelector('.section-b .right');
gsap.to(leftEl, {
scrollTrigger: leftEl, // start the animation when ".box" enters the viewport (once)
x: 500
});
</script>