https://github.com/kunukn/tween
https://github.com/kunukn/tween
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kunukn/tween
- Owner: kunukn
- License: mit
- Created: 2018-01-30T15:35:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-26T08:01:06.000Z (about 6 years ago)
- Last Synced: 2025-03-16T14:54:29.987Z (2 months ago)
- Language: JavaScript
- Size: 122 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tween
Run a tween with fixed duration. Update callback is invoked on progress of the tween. The progress is a range value from [0;1].
The value 0 and 1 is guaranteed to be called during the tween.## usage
examples
```
var tween = require("@kunukn/tween");
var log = console.log.bind(console);function onComplete(arg){
log(arg);
log('** example done');
}log('** example start');
tween({ duration: 500, update: log, complete: onComplete });
``````
import tween from '@kunukn/tween';
const onUpdate = range => console.log(range);
const onComplete = ({ startTime, now, elapsedTime }) => console.log(startTime, now, elapsedTime);
tween({ duration: 500, update: onUpdate, complete: onComplete });
```tween arguments:
* duration in milli seconds
* update is a function called on tween update with range value between [0;1]
* complete is function called when the tween is done## npm
https://www.npmjs.com/package/@kunukn/tween
## cdn
https://unpkg.com/@kunukn/tween/