Jump to content
Search Community

Animating along a path

CarpeDiem test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I am using the morph SVG plug in to animate a PNG along a path that I drew in illustrator.  I saved the SVG code as my path and the animation works okay EXCEPT  i want the animation to happen in the reverse direction.

 

Here is my path code:

<svg width="800" height="800">

  
  <path id="anim_path" class="st458" d="M353.7,27.4c0,0-262.6,1.6-264.2,87.4s165.4,169.7,165.4,169.7" fill="none" stroke="black"/>
</svg>
  
and here is the script:
 
var tl = new TimelineMax({paused:true});
var bezierData = MorphSVGPlugin.pathDataToBezier("#anim_path");
tl.set("#chip", {autoAlpha:1, xPercent:-50, yPercent:-50});
tl.to("#chip", 1, {bezier: {values:bezierData, type:"cubic", autoRotate:90}, ease:Linear.easeNone, repeat:0, yoyo:false});
tl.play();
 
 
Any ideas as to what I did wrong.
Link to comment
Share on other sites

Your bezierData is an array, so why don't you try reversing it. 

var bezierData = MorphSVGPlugin.pathDataToBezier("#anim_path").reverse();

That reverse method is not the same as GSAP's. Here's some info about reversing an array.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse

 

If that doesn't work, please provide a demo.

 

 

.

  • Like 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.
×
×
  • Create New...