Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created October 8, 2011 19:51
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronksaunders/1272779 to your computer and use it in GitHub Desktop.
Save aaronksaunders/1272779 to your computer and use it in GitHub Desktop.
spinning circle in Appcelerator
//
//
var win1 = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff',
layout : "vertical"
});
//
var view5 = Titanium.UI.createView({
backgroundColor : '#336699',
top : 60,
height : 200,
width : 200,
anchorPoint : {
x : 0.5,
y : 0.5
}
});
win1.add(view5);
var spin = Titanium.UI.createButton({
title : 'spin',
height : 40,
width : 200,
left : (320 - 200) / 2,
top : 100
});
var rotate = function(degrees) {
var t = Ti.UI.create2DMatrix();
t = t.rotate(degrees);
var a = Titanium.UI.createAnimation();
a.transform = t;
a.duration = 5;
view5.animate(a);
setTimeout(function() {
rotate(++degrees);
}, 5);
};
spin.addEventListener('click', function() {
rotate(0);
});
win1.add(spin);
win1.open();
@write2lloyd
Copy link

Hi Aaron. Thanks for this code. It works perfectly. However is there a way to stop the spin on click of a button. Can't seem to get it to stop. Any help would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment