Skip to content

Instantly share code, notes, and snippets.

@ef4
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save ef4/4d190386939f5cd1437a to your computer and use it in GitHub Desktop.

Select an option

Save ef4/4d190386939f5cd1437a to your computer and use it in GitHub Desktop.
init();
animate();
function init() {
var output = document.createElement( 'div' );
output.style.cssText = 'position: absolute; left: 50px; top: 300px; font-size: 100px';
document.body.appendChild( output );
var tween = new TWEEN.Tween( { x: 50, y: 0 } )
.to( { x: 400 }, 2000 )
.easing( TWEEN.Easing.Elastic.InOut )
.onUpdate( function () {
output.innerHTML = 'x == ' + Math.round( this.x );
var transform = 'translateX(' + this.x + 'px)';
output.style.webkitTransform = transform;
output.style.transform = transform;
} )
.start();
}
function animate(time) {
requestAnimationFrame( animate ); // js/RequestAnimationFrame.js needs to be included too.
TWEEN.update(time);
}
var output = document.createElement('div');
output.style.cssText = 'position: absolute; left: 50px; top: 300px; font-size: 100px';
document.body.appendChild( output );
$(output).velocity({translateX: [400, 50]}, {duration: 2000, easing: 'easeInOut'}).then(function(){
console.log("Velocity returns a Promise.");
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment