Jump to content
Search Community

MotionPathPlugin: Option to *not* add current target's position to the start of the path array?

gaggo test
Moderator Tag

Recommended Posts

Hi there, just a quick question: In the documentation of MotionPathPlugin, it says this:

 

// plot a curve through these coordinates. The target's current coordinates will automatically be added to the start:
motionPath: [{x:100, y:50}, {x:200, y:0}, {x:300, y:100}]

Is there also an option to NOT add the target's current coordinates to the path?

Link to comment
Share on other sites

1 hour ago, OSUblake said:

So you want it to start at 100,50? 

 

Then just set it to that coordinate first.

 


gsap.set(".foo", {
  x: 100,
  y: 50
});

gsap.to(".foo", {
  motionPath: [{x:200, y:0}, {x:300, y:100}]
});

 

Oh... that's how easy this is :)

Thanks!!

Link to comment
Share on other sites

I've seen this kind of question before and I think it's worth adding a new "fromCurrent" property to MotionPathPlugin so you can set it to false here:

gsap.to(".foo", {
  motionPath: {
    path: [...],
    fromCurrent: false // DON'T put the current values into the start of the path
  }
});

 

You can preview it in this file: https://assets.codepen.io/16327/MotionPathPlugin.min.js

 

Cool? I'm open to other name suggestions, but fromCurrent seemed relatively intuitive. 

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