fregante / gsap-then

🙏 Make every GSAP Tween a promise. tl.then(doSomething) (GSAP 1 and 2)
https://npm.im/gsap-then
MIT License
29 stars 3 forks source link

Check for function first, support for Promise.all #3

Closed tprovick closed 5 years ago

tprovick commented 5 years ago

This was one of multiple promises I was waiting for via Promise.all, but if I created the promise by calling then() without passing in a function, it threw an error. It was relatively easy just to pass an empty function in, but I thought I would also add the check to the library so I didn't need to.

I thought if I found it useful, someone else might, so I created a PR.

fregante commented 5 years ago

You don't need to create a new promise by calling .then specifically, all tweens are already promises. Use:

Promise.all([
    TweenLite.to(...)
]);

Promise.all will pass a resolve function to gsap-then's .then so this should already work as is.


I can't merge this as is because it changes the return value of that .then

Sadly I didn't write any tests to verify the behavior.

tprovick commented 5 years ago

You're completely right. I was trying to wrap something up and didn't think this all the way through.

I was having a problem with Promise.all and a timeline, but I'll revisit and see if it can't be solved in another way. Thanks for the response.