# gsap-then

> Make every GSAP Tween a promise. tl.then(doSomething)

Latest version **3.0.0** (published 2019-03-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install gsap-then
pnpm add gsap-then
yarn add gsap-then
bun add gsap-then
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2019-03-19 |
| First published | 2016-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Federico Brigante |
| Maintainers | bfred-it |
| Keywords | gsap, greensock, tweenlite, tweenmax, timelinelite, timelinemax, promise, then, thenable |

## Links

- npm: https://www.npmjs.com/package/gsap-then
- Repository: https://github.com/bfred-it/gsap-then
- Homepage: https://github.com/bfred-it/gsap-then#readme
- Issues: https://github.com/bfred-it/gsap-then/issues
- npm.io page: https://npm.io/package/gsap-then

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2019-03-19
- 2.1.1 — 2016-09-29
- 2.1.0 — 2016-09-16
- 2.0.2 — 2016-09-14
- 2.0.0 — 2016-09-14
- 1.0.1 — 2016-08-19
- 1.0.0 — 2016-08-19

## README

# <img src="https://rawgit.com/bfred-it/gsap-then/master/logo.svg" width="45" align="left"> gsap-then

> Make every GSAP Tween a promise

[![gzipped size](https://badges.herokuapp.com/size/github/bfred-it/gsap-then/master/dist/gsap-then.browser.js?gzip=true&label=gzipped%20size)](#readme)
[![Travis build](https://api.travis-ci.org/bfred-it/gsap-then.svg?branch=master)](https://travis-ci.org/bfred-it/gsap-then)
[![npm link](https://img.shields.io/npm/v/gsap-then.svg)](https://www.npmjs.com/package/gsap-then)

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

Since v3.0.0 it supports `await`!

## Install

```sh
npm install --save gsap-then
```

```js
import 'gsap';
import 'gsap-then';
```

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

## Usage

```js
TweenLite.to('.title', 1, {opacity: 0}).then(function () {
	console.log('Done animating title');
})
```

```js
Promise.all([
	TweenLite.to('.title', 1, {opacity: 0}),
	loadImage('img.jpg') // http://npm.im/image-promise
]).then(function () {
	console.log('Animation done and image loaded');
});
```

```js
var tl = new TimelineLite();
tl.then(function () {
	console.log('Timeline completed:', tl);
})
tl.to('.title', 1, {opacity: 0});
```

```js
await TweenLite.to('.title', 1, {opacity: 0});

console.log('Done animating title');
```

## Notes

* Calling `.then()` generates a new Promise.
* The generated Promise is resolved the next time GSAP calls `onComplete`
* The Promise is only resolved once, so if you restart the animation, nothing new will happen—unless you generate a new Promise.
* If the tween already has an `onComplete` callback, it will be replaced by the Promise, but it will still work.
* Don't remove or set a new `onComplete` callback **after** calling `.then()` because this will override the Promise (i.e. it will never be resolved)

## Dependencies

*  Load `gsap` or simply `TweenLite` before `gsap-then`.
* `window.Promise` is available in Edge 12+ and all the [other browsers.](http://caniuse.com/#feat=promises)

## Related

* [GSAP](https://github.com/greensock/GreenSock-JS): GreenSock Animation Platform, duh!

## License

MIT © [Federico Brigante](http://twitter.com/bfred_it)

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

---
_Source: https://npm.io/package/gsap-then · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
