Share Posted February 13, 2014 hi as well as playing back an animated visualisation I want to users to be able to jump from point to point. If I set labels in the animation they point to the start of an animation sequence not its end point. While I can use getLabelAfter() etc + an offset that seems a kludge Is there a means to go to a label play back that sequence & stop? I've got a simple codepen derived demo at: http://thisthen.co.uk/gsaptest/ Mark Link to comment Share on other sites More sharing options...
Share Posted February 13, 2014 Hello marko, Have you looked into the seek() method: http://api.greensock.com/js/com/greensock/TimelineLite.html#seek() //jumps to exactly 2 seconds myAnimation.seek(2); //jumps to exactly 2 seconds but doesn't // suppress events during the initial move: myAnimation.seek(2, false); //jumps to the "myLabel" label myAnimation.seek("myLabel"); Taken from TimelineMax DOCS: seek() : Jumps to a specific time (or label) without affecting whether or not the instance is paused or reversed. If there are any events/callbacks inbetween where the playhead was and the new time, they will not be triggered because by default suppressEvents (the 2nd parameter) is true. Think of it like picking the needle up on a record player and moving it to a new position before placing it back on the record. If, however, you do not want the events/callbacks suppressed during that initial move, simply set the suppressEvents parameter to false. Parameters position:* — The position to go to, described in any of the following ways: a numeric value indicates an absolute position, like 3 would be exactly 3 seconds from the beginning of the timeline. A string value can be either a label (i.e. "myLabel") or a relative value using the "+=" or "-=" prefixes like "-=2" (2 seconds before the end of the timeline) or a combination like "myLabel+=2" to indicate 2 seconds after "myLabel". suppressEvents:Boolean (default = true) — If true (the default), no events or callbacks will be triggered when the playhead moves to the new position defined in the time parameter. Returns * — self (makes chaining easier) Does that help? Link to comment Share on other sites More sharing options...
Author Share Posted February 13, 2014 hi thanks for getting back doesn't solve problem that labels are at start of sequences gotoAndStop + an offset works for now, I just hoped for a more elegant solution I guess at some point I can look at having child timelines - but I'm still figuring basic stuff at the moment Mark Link to comment Share on other sites More sharing options...
Share Posted February 13, 2014 You can use TimelineMax's tweenFromTo() to tween from one label to another label http://api.greensock.com/js/com/greensock/TimelineMax.html#tweenFromTo() timeline.tweenFromTo("march", "feb"); or you can use tweenTo("feb") or tweenTo(tl.getLabelAfter()) ... lots of possibilities. Also you could look into using addPause() throughout your timeline tl.add("march") tl.to(someMarchThing, 1, {left:200}) tl.addPause() tl.add("feb") tl.to(someFebThing, 1, {left:200}) tl.addPause() if you do tl.play("march") the timeline will start playing at the march label and then stop where the addPause() was inserted. --- Thanks for the demo, but its best to link to the demo on CodePen so that we can see what's happening and offer better solutions. 2 Link to comment Share on other sites More sharing options...
Author Share Posted February 13, 2014 hi thanks I will check those out code pen - I couldn't figure out how to add the text plugin Mark Link to comment Share on other sites More sharing options...
Share Posted February 13, 2014 You can just fork the TextPlugin pen I created for you in your other post. Instructions here: http://forums.greensock.com/topic/9002-read-this-first-how-to-create-a-codepen-demo/#entry35999 The forked copy you create should have TextPlugin loaded. Link to comment Share on other sites More sharing options...
Author Share Posted February 13, 2014 thanks Mark 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