Share Posted March 2, 2015 Greetings! I have my first TweenMax doing everything i need, (including interaction with externals controls/buttons) but I'm drawing a blank as how to prevent it from 'autoplay' My relevant 1liner: var tl = TweenMax.to(point, currentSpeed, {css: { left: "95%"}, repeat:repeat, yoyo:true, repeatDelay:0, ease:Linear.easeNone}); ... so for example my 'pause' button works fine: $('#pause').click( function(){tl.pause();}); ... how do I make it start only when I press my $('#start') button? I figure I missed something simple, hence my apologies and thanks in advance. Link to comment Share on other sites More sharing options...
Share Posted March 2, 2015 Hi tomekpilot You need to add paused:true in your Tween Vars , pls try this : var Anim = TweenMax.to( "#foo" , 1 ,{ ....... , paused:true }) ; $('#play').click( function(){ Anim.play() }) ; pls check this out , same method with Timeline : See the Pen Wbyazp by GreenSock (@GreenSock) on CodePen 4 Link to comment Share on other sites More sharing options...
Author Share Posted March 2, 2015 ... ahhhh, that's what what I meant by 'something simple'.Thanks! works like magic now. Link to comment Share on other sites More sharing options...
Share Posted March 2, 2015 To add to Diaco.AW's great advice.. here is how to start with timeline paused using TimelineMax / TimelineLite: var Anim = new TimelineMax({paused:true}); Anim.to("#foo", 1, {left: "95%"}); $("#play").click(function(){ Anim.play() }) ; : Hope this helps! 3 Link to comment Share on other sites More sharing options...
Share Posted July 23, 2015 What if I'm not using jQuery? Link to comment Share on other sites More sharing options...
Share Posted July 23, 2015 Same thing. You just need to type a few extra characters var Anim = new TimelineMax({paused:true}); Anim.to("#foo", 1, {left: "95%"}); document.querySelector("#play").addEventListener("click", function(){ Anim.play(); }); 1 Link to comment Share on other sites More sharing options...
Share Posted August 12, 2015 Hi, Does anyone know how to change this from targeting... #foo to targeting... $(this).closest('.foo') so that I'm animating the nearest .foo ancestor of the clicked element? Thanks! Link to comment Share on other sites More sharing options...
Share Posted August 12, 2015 Just add an animation to your click function. Here's an example with a bunch of nested foo classes. It doesn't use jQuery, but it's the same concept. See the Pen MwRgrw by osublake (@osublake) on CodePen 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