Tween-Play-Pause
This is a derivative of the Tween.JS library by Sole on Github.com.
For more documentation head over to their repository.
JavaScript tweening engine for easy animations, incorporating optimised Robert Penner's equations.
var coords = { x: 0, y: 0 };
var duration = 1000;
var endCoords = { x: 100, y: 100 };
var tween = new TWEEN.Tween(coords)
.to(endCoords, duration)
.onUpdate(function() {
console.log(this.x, this.y);
coords.x = this.x;
coords.y = this.y;
})
.start();
requestAnimationFrame(animate);
function animate(time) {
requestAnimationFrame(animate);
TWEEN.update(time);
}
tween.play();
tween.pause();
Installation
Download the library and include it in your code:
<script src="js/Tween.js"></script>
More advanced users might want to...
Use npm
npm install tween-play-pause