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

gsap-then

Make every GSAP Tween a promise

gzipped size Travis build npm link

Good news! GSAP 3 [supports promises](https://greensock.com/docs/v3/GSAP/Tween/then()) natively! This module is only necessary for GSAP v1 and v2.

Once loaded, every GSAP tween (TweenLite, TimelineLite, TweenMax, TimelineMax) will automatically be a promise. See the usage examples to see what this enables.

Install

npm install --save gsap-then
import 'gsap';
import 'gsap-then';

Or include the file dist/gsap-then.browser.js after loading GreenSock.

Usage

TweenLite.to('.title', 1, {opacity: 0}).then(function () {
    console.log('Done animating title');
})
Promise.all([
    TweenLite.to('.title', 1, {opacity: 0}),
    loadImage('img.jpg') // https://npm.im/image-promise
]).then(function () {
    console.log('Animation done and image loaded');
});
var tl = new TimelineLite();
tl.then(function () {
    console.log('Timeline completed:', tl);
})
tl.to('.title', 1, {opacity: 0});
await TweenLite.to('.title', 1, {opacity: 0});

console.log('Done animating title');

Notes

Dependencies

Related

License

MIT © Federico Brigante

gsap-then is NOT affiliated with, endorsed, or sponsored by GreenSock, Inc.