Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created June 1, 2012 23:34
Show Gist options
  • Save alanleard/2855765 to your computer and use it in GitHub Desktop.
Save alanleard/2855765 to your computer and use it in GitHub Desktop.
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
});
menu.addEventListener('touchmove', function(evt) {
var point = menu.convertPointToView({ x: evt.x, y: evt.y }, win);
menu.top = point.y;
});
menu.addEventListener('touchend', function(e){
if(menu.top <((Ti.Platform.displayCaps.platformHeight/2)+100) && menu.top >((Ti.Platform.displayCaps.platformHeight/2))){
menu.top = Ti.Platform.displayCaps.platformHeight/2;
} else if (menu.top >(Ti.Platform.displayCaps.platformHeight/2)+100){
menu.top = Ti.Platform.displayCaps.platformHeight-50;
} else if (menu.top <((Ti.Platform.displayCaps.platformHeight/2))){
menu.top = 100;
}
})
win.add(menu);
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment