Skip to content

Instantly share code, notes, and snippets.

View alanleard's full-sized avatar

Alan Leard alanleard

View GitHub Profile
@alanleard
alanleard / app.js
Created December 19, 2011 21:33
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,
@alanleard
alanleard / app.js
Created December 19, 2011 22:02
Simple Shake
var win = Ti.UI.createWindow();
function shakeAnimation(view, count, distance) {
var anim1 = Ti.UI.createAnimation({
duration:100,
left:view.left-distance,
autoreverse:true,
curve:Ti.UI.iOS.ANIMATION_CURVE_LINEAR,
repeat:count
@alanleard
alanleard / app.js
Created December 19, 2011 22:09
Center Shake
var win = Ti.UI.createWindow();
function shakeAnimation(view, count, distance) {
var anim1 = Ti.UI.createAnimation({
duration:50,
left:view.left-distance,
autoreverse:true,
curve:Ti.UI.iOS.ANIMATION_CURVE_LINEAR
});
@alanleard
alanleard / app.js
Created December 19, 2011 22:24
Shake Animation
var win = Ti.UI.createWindow();
function shakeAnimation(view, count, distance, speed) {
var anim1 = Ti.UI.createAnimation({
duration:speed/2,
left:view.left-(distance/2),
curve: Ti.UI.iOS.ANIMATION_CURVE_EASE_IN
});
var anim2 = Ti.UI.createAnimation({
@alanleard
alanleard / app.js
Created January 5, 2012 22:32
Image Display webview vs image
var win = Ti.UI.createWindow();
var webview = Ti.UI.createWebView({
html:'<html><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><img src="http://b.vimeocdn.com/ps/929/929705_300.jpg"></html>'
});
win.add(webview);
// var image =Ti.UI.createImageView({
// image:'http://b.vimeocdn.com/ps/929/929705_300.jpg',
// width:'100%',
@alanleard
alanleard / app.js
Created January 7, 2012 00:12
Remote Notification in App Action
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
backgroundColor: 'white'
@alanleard
alanleard / app.js
Created March 7, 2012 01:53
Circle Pictures
var win = Ti.UI.createWindow({backgroundColor:'#000'});
var dialog = Titanium.UI.createOptionDialog({
options: ['Camera','Gallery', 'Cancel'],
cancel:2
});
dialog.show();
@alanleard
alanleard / app.js
Created May 30, 2012 16:27
Menu Animation
var win = Ti.UI.createWindow();
var mainView = Ti.UI.createView();
var parent1 = Ti.UI.createView({top:0, bottom:0, backgroundColor:'blue'});
var parent1Child1 = Ti.UI.createView({top:50, bottom:0, backgroundColor:'green'});
parent1.add(parent1Child1);
@alanleard
alanleard / app.js
Created June 1, 2012 23:34
2 height draggable menu
var win = Ti.UI.createWindow({
backgroundColor: '#333'
});
var menu = Ti.UI.createView({
backgroundColor:'blue',
top:Ti.Platform.displayCaps.platformHeight-50,
bottom:0
});
@alanleard
alanleard / app.js
Created July 18, 2012 21:21
Underline function
var win = Ti.UI.createWindow();
win.open();
function label(args){
var view = Ti.UI.createView({
width:'size',
height:'size',
layout:'vertical'
});