Jump to content
Search Community

Animation time tracker

elsha 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

Hey there ...

 

I've been creating some of my first banner ads using GSAP and I've come across a little snag which would normally be as simple as looking at a timeline in flash.

I need to keep track of how much time has passed for my animation. Aside from sitting and calculating the length of each command -+ the delay times, has anyone come across an easy way of tracing/tracking the duration of GSAP animations? 

 

I'm loving GSAP though... tried GWD, edge and canvas in flash, but after an initial learning curve of GSAP, hand coding has definitely been the most powerful and easiest to control.

 

Thanks

Link to comment
Share on other sites

Hi elsha,

 

One of the greatest things about GSAP is that every animation has a number of methods for inspecting its time(), duration(), totalDuration() and more.

 

While you are working you can get the duration of a timeline with myTimeline.duration() like

 

var tl = new TimelineLite();

tl.to("#redBox", 1, {x:550})
  .to("#blueBox", 2, {x:550}, "-=0.5")
  .to("#redBox", 0.5, {x:0})
  .to("#redBox", 0.3, {rotation:360}, "+=1")

$("h1 span").text(tl.duration()) //4.3

http://codepen.io/GreenSock/pen/RWbjqx?editors=001

 

If you want to keep track of the time() (and other info) while an animation is playing check this out

 

http://codepen.io/GreenSock/pen/FnsqC

 

Be sure to check out the TimelineLite/Max docs too: http://greensock.com/docs/#/HTML5/GSAP/TimelineLite/

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