Skip to content

Commit

Permalink
chore: update tween link example
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Dec 13, 2017
1 parent 39530ad commit c4d17af
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions examples/TweenLink.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,41 @@ <h1>Tween</h1>
box = document.createElement('div');
box.id = 'box';
box.className = 'box';
box.x = 50;
box.y = 50;
box.x = 0;
box.y = 0;
gameContainer.appendChild(box);

setTimeout(runLink, 100);
Tween.to(box, {x:50, y:50}, {
duration: 500,
onUpdate: onUpdateTransform,
onComplete: runLink
});
}

function runLink(){
Tween.to(box, {x:50, y:150}, {
duration: 500,
onUpdate: onUpdate
onUpdate: onUpdateTransform
})
.link(Tween.to(box, {x:150, y:150}, {
.link(Tween.to(box, {x:150}, {
duration: 500,
onUpdate: onUpdate,
onUpdate: onUpdateTransform,
delay:'+0'
}))
.link(Tween.to(box, {x:150, y:50}, {
.link(Tween.to(box, {y:50}, {
duration: 500,
onUpdate: onUpdate,
onUpdate: onUpdateTransform,
delay:'+0'
}))
.link(Tween.to(box, {x:50, y:50}, {
.link(Tween.to(box, {x:50}, {
duration: 500,
onUpdate: onUpdate,
onUpdate: onUpdateTransform,
delay:'+0',
onComplete:runLink
}))
}

function onUpdate(ratio, tween){
function onUpdateTransform(ratio, tween){
tween.target.style.webkitTransform = 'translate(' + tween.target.x + 'px,' + tween.target.y + 'px)';
}
</script>
Expand Down

0 comments on commit c4d17af

Please sign in to comment.