Last active
August 29, 2015 14:07
-
-
Save ef4/4d190386939f5cd1437a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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