Jump to content

MadderMax

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

4 Newbie

About MadderMax

  • Rank
    Newbie
  1. Ohhhh snap guys, thats exactly what I was looking for! Blake - I had no idea I could do t.vars.onComplete() AFTER the timeline has been initialized, thats what was making all of this so difficult for me. Carl - Also a great suggestion, I learned a few new techniques thanks to you guys. Appreciate the responses and help guys, Cheers.
  2. You're absolutely right - maaaaaybe I can spark a solution with this: I HAVE been able to turn a timeline into a promise using this method, but where I get stuck with this approach is I dont know how to call .play() or .reverse() when I set up the encapsulation this way var timelinePromise = function(){ return new Promise(function(resolve){ var t = new TimelineLite({ paused: true, onComplete: function(){ console.log('on complete resolving') resolve(true) } }).to( $('.testing'), 1, { width: 200, height: 200 } ); t.play(); }); } timelinePromise().then(function(res){ console.log('promise resolved') }); CP for refrence: http://codepen.io/koolhaus/pen/ef5a47e2927f66b3791ecc5a346c6067?editors=0010 Ive been able to successfully use Tweens this way, but the point of a timeline here is that I can keep play/reversing the animation where as the Tweens ive used have been a one time execution.
  3. Hopefully I can explain this without writing up a Codepen since Backbone takes a minute to get going, if this is unclear Ill gladly set it up tho. I want to chain a timeline animation into another function, WITHOUT referencing my view in the "onComplete" of the timeline. My idea is to do this with the new Promise object in JS, but I have no idea how to do this. Here is what I got so far // some random BB function var ping = function(){ console.log('promise finished') }; // define our timeline var t = new TimelineLite({ paused: true, onComplete: function(){ // what do I return here to be able to chain a promise } }); // run the chain t.play().then(function(res){ ping() }); Obviously this doesn't work since .play() doesn't return anything, but I'm hoping there is a way to combo a .then() from the onComplete param of the timeline. Thanks in advance and happy to be posting on the forum for the first time. p.s. I know I can technically pass the view itself into the timeline and trigger a function from onComplete or an event, but I'm (1) trying to keep BB and GS decoupled, and (2) curious if my question has an answer regardless if it's the better solution.