I'm trying to fly bird svg with scrolltrigger.. it flips back when it reaches the end point of scroll scrub, i want to flip that if i scrollup in middle of end point.
Here's my code:
.bird {
transform: scaleX(1);
}
.bird-flip {
transform: scaleX(-1) !important;
}
const tl = gsap
.timeline({
scrollTrigger: {
trigger: bird,
start: "top 80%",
scrub: 1,
onEnter: () => {
birdTwo.classList.remove("bird-flip");
console.log("entered");
},
onLeave: () => {
birdTwo.classList.add("bird-flip");
console.log("leaved");
},
onEnterBack: () => {
birdTwo.classList.add("bird-flip");
console.log("enteredback");
},
onLeaveBack: () => {
birdTwo.classList.remove("bird-flip");
console.log("leavedback");
},
ease: Sine.easeOut,
markers: false,
},
})
.to(bird, {
x: 120,
rotation: 25,
})
.to(bird, {
x: 320,
rotation: -20,
})
.to(bird, {
x: 520,
rotation: 25,
})
.to(bird, {
x: 600,
rotation: 20,
})
.to(bird, {
x: 700,
rotation: -20,
})
.to(bird, {
x: 920,
rotation: 25,
})
.to(bird, {
x: 1100,
rotation: 20,
})
.to(bird, {
x: 1280,
rotation: -20,
})
.to(bird, {
x: 1400,
rotation: 25,
})
.to(bird, {
x: 1600,
rotation: 20,
})
.to(bird, {
x: 1940,
rotation: -20,
})
.to(bird, {
x: 2040,
rotation: -20,
});