Share Posted February 24, 2013 Is there an easy way to get the time of a label in a nested timeline? Link to comment Share on other sites More sharing options...
Share Posted February 24, 2013 How about this?: yourTimeline.getLabelTime("yourLabel"); http://api.greensock.com/js/com/greensock/TimelineLite.html#getLabelTime() Link to comment Share on other sites More sharing options...
Author Share Posted February 24, 2013 getLabelTime and getLabelsArray do not seem to return the labels of nested timelines though. Check out this fiddle: http://jsfiddle.net/brettm523/fa7Wd/ I've tried calling these methods on the nested timeline directly, but that gets me the time relative to the nested timeline, not the parent timeline. Link to comment Share on other sites More sharing options...
Share Posted February 24, 2013 Hi, It looks like you're asking for the parent's timeline labels and time, not the nested one, therefore the array is empty. Change your code to this: var tl1 = new TimelineMax(); var tl2 = new TimelineMax(); tl2.addLabel("tl2"); tl1.append(tl2); console.log(tl2.getLabelTime("tl2")); console.log(tl2.getLabelsArray()); I also took the liberty to update your fiddle so you can see it working: http://jsfiddle.net/fa7Wd/13/ Hope this helps, Cheers, Rodrigo. Link to comment Share on other sites More sharing options...
Author Share Posted February 24, 2013 Thanks for the reply. I know I can do that, but it's not what I want. If I call these methods on the nested timeline directly, it returns the time relative to the nested timeline. I need the time relative to the parent timeline. Granted, in my simple example, they would be the same time since there are no other offsets. I've updated the original fiddle to add delays to the parent and nested timeline. What I would like is to get the the value of 10 back (where the label falls in the overall timeline), but all I am able to retrieve is the value of 5 by querying the nested timeline. Link to comment Share on other sites More sharing options...
Share Posted February 24, 2013 Each tween or timeline has a startTime() http://api.greensock.com/js/com/greensock/core/Animation.html#startTime() So if you are only nesting your timeline with the labels 1 level deep, you can just add the timeline's startTime() to the label's time() var tl1 = new TimelineMax(); var tl2 = new TimelineMax(); tl2.append(new TimelineMax({delay: 5})); tl2.append("tl2"); tl1.append(new TimelineMax({delay: 5})); tl1.append(tl2); console.log(tl1.getLabelTime("tl2")); console.log(tl1.getLabelsArray()); console.log(tl2.getLabelTime("tl2") + tl2.startTime()); //output 10 Check out this thread here: http://forums.greensock.com/topic/7046-nested-relative-tween-time-position/#entry26178 There is some handy info about finding any tween's startTime() relative to any ancestor. I imagine you could use the same technique to recursively figure out any timeline's labelTime relative to any ancestor timeline. 1 Link to comment Share on other sites More sharing options...
Author Share Posted February 24, 2013 You guys are rockstars. Thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now