Share Posted March 18, 2016 Is there a way to set the onUpdate when doing a Tween to be less frequent... basically I'm doing a very slow slideshow of images that pan past the screen and it calculates which one is most on screen so it can display the correct caption... the scroll is super slow so any extra processing power would be nice to keep it as buttery smooth as possible... so really I only want the onUpdate to be called every second for example... Is there anything like that built in? Before I reinvent the wheel 1 Link to comment Share on other sites More sharing options...
Share Posted March 18, 2016 Hi mimeartist you can try something like this : var ticker = new com.greensock.Ticker(1); // tick once per second ticker.addEventListener("tick", render); function render(){ console.log('hi') }; // render is your function to call and can be whatever you want TweenMax.to('.ball', 30 ,{x:200 , onStart:function(){ ticker.addEventListener("tick", render); }, onComplete:function(){ TweenLite.delayedCall(0.01,function(){ ticker.removeEventListener("tick", render) } ) } }); 4 Link to comment Share on other sites More sharing options...
Author Share Posted March 18, 2016 Thanks Diaco, Is Ticker a greensock thing then? Will give it a go! Link to comment Share on other sites More sharing options...
Author Share Posted March 18, 2016 Also as a side... I've kill the tween under certain circumstances... do I need to remove the listener, or does the onComplete perform that? I'm assuming that I could in effect set up a setInterval that does the same thing? Link to comment Share on other sites More sharing options...
Share Posted March 18, 2016 yep it's one of the GSAP engine options . and onComplete will remove listener but if you kill before tween complete , you should to remove that with this : ticker.removeEventListener("tick", render); and another way is this ( without addListener ) : var tick = 0; TweenMax.to('.ball', 30 ,{x:200 , onStart : function(){ tick = 0 }, onUpdate : function(){ tick++ ; if ( tick%60 == 0 ){ // your function call or whatever } } }); 1 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