Skip to content

Instantly share code, notes, and snippets.

@jasonkneen
Created May 15, 2014 14:45
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jasonkneen/bc936540ae9fedc8fa2b to your computer and use it in GitHub Desktop.
Save jasonkneen/bc936540ae9fedc8fa2b to your computer and use it in GitHub Desktop.
Demonstrate CollapsableView Tag in Alloy.
function collapse(){
$.myView.collapse();
// $.myView.expand();
}
<Alloy>
<CollapsableView module="ui" id="myView" height="200" width="Ti.UI.FILL" layout="vertical">
<Label top="20">Hello there</Label>
<Button top="20" onClick="collapse">Collapse Me</Button>
</CollapsableView>
</Alloy>
// put in the lib folder
exports.createCollapsableView = function(args) {
var view = Ti.UI.createView(args);
view.collapse = function() {
view.expandedHeight = view.expandedHeight || view.height;
view.height = 0;
};
view.expand = function() {
view.height = view.expandedHeight;
};
return view;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment