Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created December 19, 2011 21:33
Show Gist options
  • Save alanleard/1498983 to your computer and use it in GitHub Desktop.
Save alanleard/1498983 to your computer and use it in GitHub Desktop.
Wobble
var win = Ti.UI.createWindow();
function shakeAnimation(view) {
view.transform = Ti.UI.create2DMatrix().rotate(1);
var r1 = Ti.UI.create2DMatrix().rotate(2);
var r2 = Ti.UI.create2DMatrix().rotate(-2);
var anim1 = Ti.UI.createAnimation({
duration:200,
transform:r1,
});
var anim2 = Ti.UI.createAnimation({
duration:200,
transform:r2,
});
view.animate( anim2 );
anim2.addEventListener('complete',function(){
view.animate( anim1 );
});
anim1.addEventListener('complete',function(){
view.animate( anim2 );
});
}
var view = Ti.UI.createView({
backgroundColor:'blue',
height:57,
width:57,
borderRadius:5
});
win.add(view);
shakeAnimation(view);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment