Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
benoit

MotionPath and getLength

Recommended Posts

Hi,

Close, but don't find how to get the length of a motionPath.

 

const rawPath = MotionPathPlugin.arrayToRawPath([{x:0,y:10},{x:50,y:1000}], {curviness:2});
const d = MotionPathPlugin.rawPathToString(rawPath);
console.log(DrawSVGPlugin.getLength(d)); // hum

 

Link to comment
Share on other sites

You have to use a path element for that.

 

const rawPath = MotionPathPlugin.arrayToRawPath([{x:0,y:10},{x:50,y:1000}], {curviness:2});
const d = MotionPathPlugin.rawPathToString(rawPath);
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", d);

// same thing
console.log(path.getTotalLength())
console.log(DrawSVGPlugin.getLength(path))

 

  • Like 4
Link to comment
Share on other sites

Is that in the docs? That link just defaults to the docs home page for me.

  • Like 1
Link to comment
Share on other sites

I think it was just added, so you have to clear your cache.

 

  • Like 3
Link to comment
Share on other sites

Yep - whoop there it is.

  • Like 2
Link to comment
Share on other sites

Typical @GreenSock. "Oh BTW I added something cool 6 months ago and forgot to tell you about it." :D

  • Like 1
  • Haha 1
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.
×