Jump to content
GreenSock

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

How to Loop Animation Before it Ends

Recommended Posts

Hey guys,

I'm trying to create an animation for a cup of coffee that has hot steam leaving it. The idea is to have 2 curved lines that constantly move up on the y-axis. The top and bottom of the paths are hidden behind a mask. 

My goal is to have the paths constantly move up with the illusion that it's constant. Right now you can see the path has to stop, then reset its position before moving back up.

I hope this makes sense. Is this possible?

See the Pen MmPNgp by stinkytofu3311 (@stinkytofu3311) on CodePen

Link to post
Share on other sites

Thanks for the demo. If i understand correctly you just need to find a loop position where the beginning state matches the end. I played around with some numbers and came up with:

 

See the Pen vZORVe?editors=1010 by GreenSock (@GreenSock) on CodePen

 

  • Like 1
Link to post
Share on other sites

Wow Carl That looks great. That's exactly what i needed. Could you explain what the {y:13},{y-2...}) does? I've never seen it set up that way before. 

Link to post
Share on other sites

no problem, the fromTo() method allows you to specify both starting and ending values for an animation.

 

tl.fromTo(coffeeSteam,1, {y:13},{y:-2, repeat:-1, ease:Power0.easeNone})

 

That code means we want to animate the y of coffeeSteam from a y of 13 to a y of -2.

 

https://greensock.com/docs/#/HTML5/GSAP/TimelineLite/fromTo/

 

  • Like 3
Link to post
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.

×