Jump to content
Search Community

Scrolltrigger with motionpath for svg moving along with scroll

Vihaan2707 test
Moderator Tag

Go to solution Solved by elegantseagulls,

Recommended Posts

Hi, I am a new user of gsap, I just removed the end property and edited the other properties according to my requirements in my next.js project. The above codepen is the same as the documentation example with its end property removed. I am facing the same problem as that codepen, sometimes the car or tractor goes out of the screen while scrolling, I noticed the further the end, the slower the car moves and vice-versa. Could someone please suggest what I should do to fix this, I tried modifying start and end properties but that becomes unresponsive on different sizes.

In simple words it is not responsive for all sizes.

 

In my next.js project this is the code for the animation

 

gsap.to("#motionSVG", {
      scrollTrigger: {
        trigger: ".section.hiw",
        start: "300px 20% ",
 
        scrub: 1,
        markers: true,
        onUpdate: (self) => {
          gsap.to("#tractor", {
            rotation: () => (self.direction === 1 ? 0 : -180),
            overwrite: "auto",
          });
        },
      },
      duration: 10,
      ease: "none",
      immediateRender: true,
      motionPath: {
        path: "#motionPath",
        align: "#motionPath",
        alignOrigin: [0.5, 0.5],
        autoRotate: 90,
      },
    });

See the Pen VwrZQNq by vverma_27 (@vverma_27) on CodePen

Link to comment
Share on other sites

I do have scrub:1; should I change it to scrub:true.

I meant by that if for example, I set end property to +="2000px", then the car moves very fast and disappears under the screen, but if it is "+=5000px" it moves slower and disappears above the screen

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...