So previously I have asked about a library to animate objects when in screen, and @plucky dome recommended GSAP (Thank you very much, this is exactly what I was looking for). #1246110172401893438 message
But now when I tried using it, making a code exactly from https://gsap.com/docs/v3/Plugins/ScrollTrigger/?page=1 , the animation did not work when using scrollTrigger.
This code below works, the box moves:
import gsap from "gsap";
gsap.to(".box", {
x: 500,
rotation: 360,
duration: 3
})
But when I tried to implement scrollTrigger as the code below:
import gsap from "gsap";
gsap.registerPlugin(ScrollTrigger)
gsap.to(".box", {
scrollTrigger: {
trigger: '.box',
start: "top 80%",
end: "bottom top",
markers: true,
toggleActions: "restart pause restart pause",
},
x: 500,
rotation: 360,
duration: 3
})
It is now not moving at all, and it is not showing the UI markers like the picture:
Anyone have an idea? Thank you