Skip to content

Instantly share code, notes, and snippets.

@Topener
Created January 4, 2019 21:56
Show Gist options
  • Save Topener/7f49256c03ec2838ba0c19230f33c4e9 to your computer and use it in GitHub Desktop.
Save Topener/7f49256c03ec2838ba0c19230f33c4e9 to your computer and use it in GitHub Desktop.
A picker in Titanium that animates in from the bottom
var window = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var picker = Ti.UI.createPicker({
bottom: -300,
height: 300,
zIndex: 10,
width: Ti.UI.FILL
});
var overlay = Ti.UI.createView({
height: Ti.UI.FILL,
width: Ti.UI.FILL,
backgroundColor: "#000",
opacity: 0,
zIndex: 9
});
var label = Ti.UI.createLabel({
text: "Pick Option"
});
window.add(label);
label.addEventListener('click', showPicker);
var rows = [];
for (var i = 0; i < 10; i++) {
rows.push(Ti.UI.createPickerRow({title: i}));
}
picker.add(rows);
window.add(picker);
picker.addEventListener('change', function(e){
label.text = e.row.title
});
function showPicker(){
window.add(overlay);
overlay.animate({
opacity: 0.5
});
picker.animate({
bottom: 0,
duration: 500
});
}
overlay.addEventListener('click', hidePicker);
function hidePicker(){
overlay.animate(Ti.UI.createAnimation({
opacity: 0,
duration: 500
}), function(){
window.remove(overlay);
});
picker.animate({
bottom: -300,
duration: 500
});
}
window.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment