Share Posted January 16, 2016 Is it possible to add timeScale when playing a timeline with this method:? timeline.reverse() I'm running play timeline within a 'if scroll is this' loop and would like to reverse the timeline with faster speed on the 'else' statement like this: if (scrollTop < 64) { timeline.play(); } else { timeline.reverse(); } Thanks for your time. Yan See the Pen pgWZed?editors=001 by anon (@anon) on CodePen Link to comment Share on other sites More sharing options...
Share Posted January 16, 2016 Hi beliy333 , You can just do something like this: if (distance < 64) { timeline.play().timeScale(1); } else { timeline.reverse().timeScale(3); } Obviously, you can enter any timeScale value you like. Hopefully this helps. 4 Link to comment Share on other sites More sharing options...
Author Share Posted January 16, 2016 Oh well that's just too simple! Expanding on the question–do you see anything wrong with using either of those calls within my 'requestAnimationFrame' loop? I mean am I loading up the browser heavily by making it run those calls on repeat? Or is that a common practice when you're triggering events by scroll position and I shouldn't worry about it? Thanks, Yan Link to comment Share on other sites More sharing options...
Share Posted January 16, 2016 Personally, I use Scroll Magic for all my scroll triggered animations so I'm not sure about common or best practices. I've only played with requestAnimationFrame, but never used it in the wild for a scroll triggered animation so I'll let someone a bit more experienced with it give you that part of the answer. 1 Link to comment Share on other sites More sharing options...
Share Posted January 16, 2016 Check out this recent thread about scrolling. http://greensock.com/forums/topic/13514-reaching-tweenmax-from-local-scope/?hl=scroll#entry56483 You're doing that for the most part using rAF, although you're still running logic on every tick (calculating the scroll distance). So here's your example using GSAP's ticker and a flag. The function only gets called if a scroll happened. See the Pen bEojxr?editors=001 by osublake (@osublake) on CodePen 2 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