Skip to content

Instantly share code, notes, and snippets.

@makzan
Created December 8, 2015 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makzan/33a0ac4ef5f89ce9ba9e to your computer and use it in GitHub Desktop.
Save makzan/33a0ac4ef5f89ce9ba9e to your computer and use it in GitHub Desktop.
Tween.JS example
// data tweening
createjs.Tween.get({opacity:0,x:0}, {loop:true, onChange:render})
.to({opacity: 0.9, x:200}, 300, createjs.Ease.bounceOut)
.to({opacity: 0.3}, 300, createjs.Ease.easeOut)
.wait(200)
.to({opacity: 0.9}, 300, createjs.Ease.easeOut)
.to({opacity: 0, x:0}, 300, createjs.Ease.easeOut)
.wait(1000)
// view rendering
var avatar = document.getElementById('avatar1');
function render(event){
var data = event.currentTarget.target;
avatar.style.opacity = data.opacity+"";
avatar.style.transform = `translateX(${data.x}px)`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment