Jump to content
Search Community

Move object in percentages through a path

Comunica+A test
Moderator Tag

Recommended Posts

Hi, I'm trying to move an object trough a circle path, and I need to move it in percentage. I mean, If I pass a value of 2 trhough a variable I need that the object moves through the path 2% of that path. But I don´t find any info about move in percents trough paths. Is that possible? 


Here is the code pen:


Thank you!

See the Pen QWbdKLV by maxpower78 (@maxpower78) on CodePen

Link to comment
Share on other sites

Hey @Comunica+A,  

 

from the docs:

 

end Number - The position along the path at which to end, where 0 is the beginning, 1 is the end, and 0.5 is in the middle. It can be any positive or negative decimal number, including a value that's less than the start (which would make the object travel backwards). For example, 0.3 would have the element end at the 30% point along the curve. 1.5 would make it loop around back to the beginning and stop at the halfway point. Default is 1.

 

gsap.to("#balloon", {
  //progress:myDistance,
  duration: 4, 
  ease: "power1.inOut",
  motionPath:{
    path: "#path",
    end:0.02 // = 2 %
  }
});

 

Happy ending ...

Mikel

 

  • Like 4
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...