Hello GSAP community! How's everybody? I would like to know if you could help me. I have two timelines that are triggered by ScrollTrigger when I am within the range of the start attribute. The onEnter and onLeaveBack events of the same ScrollTrigger instance work with timeline.play () and timeline.reverse () respectively, the problem starts when the two timelines are fired and loses the smoothness of the transition.
Example: When I move from div.p3 to div.p1 tl2 is interrupted, it is interrupted by tl1 and overwrites everything. I don't quite understand if it could be fixed with invalidate or overwrite.
Thank you very much in advance!
Here I attach my codepen: https://codepen.io/cpiocova/pen/PoZVEva
<body>
<div id="box"></div>
<div class="p1 pages"></div>
<div class="p2 pages"></div>
<div class="p3 pages"></div>
</body>
const box = document.getElementById('box')
const tl1 = gsap.timeline({paused: true})
const tl2 = gsap.timeline({paused: true})
tl1.to(box, {
duration: 3,
x: 350,
y: 30,
rotation: 45,
ease: "expo.inOut"
})
tl2.to(box, {
duration: 3,
x: 20,
y: 20,
rotation: -125,
ease: "expo.inOut"
})
ScrollTrigger.create({
trigger: ".p2",
start: "0 top",
markers: true,
onEnter: () => tl1.play(),
onLeaveBack: () => tl1.reverse()
})
ScrollTrigger.create({
trigger: ".p3",
start: "0 top",
markers: true,
onEnter: () => tl2.play(),
onLeaveBack: () => tl2.reverse()
})
PD: Excuse my bad English.