The widget will create a scrollview Waterfall layout with images
Download this repository and install it:
- In your application's config.json file, include the following line in your dependencies:
"dependencies": {
"com.miga.waterfall": "1.0"
}
- Copy the
com.miga.waterfall
folder into yourapp/widgets
directory.
Or simply use the gitTio CLI:
$ gittio install com.miga.waterfall
###xml
<Widget src="com.miga.waterfall" id="waterfall"/>
###controller
####add image
// random item size:
var sx = Math.floor(Math.random() * 2) + 1;
var sy = Math.floor(Math.random() * 2) + 1;
// find maximum free width
var freeX = $.waterfall.getFreeWidth();
if (sx>freeX) {
sx=freeX;
}
// image
var img = $.UI.create("ImageView", {
image: "http://lorempixel.com/200/200/",
width: 200,
height: 200,
backgroundColor: "#fff",
});
// add item
var obj = $.waterfall.addItem({
object: img,
resize: true,
borderWidth: 1,
borderColor: "#fff",
placeholder: {
backgroundColor: "#999"
},
size: {
x: sx,
y: sy
}
});
Method | Description |
---|---|
addItem | adds a new image |
getFreeWidth | returns the maximum column width for a new item |
getItemWidth | returns the maximum image width for one cel |
clear | clears the whole list |
Feel free to improve this widget by forking, submitting pull requests or creating issues.
- 1.0 First version
This project is licensed under CC BY-SA 4.0. Please read the https://creativecommons.org/licenses/by-sa/4.0/ for more information about this license.
Appcelerator, Appcelerator Titanium and associated marks and logos are trademarks of Appcelerator, Inc.
Titanium is Copyright (c) 2008-2015 by Appcelerator, Inc. All Rights Reserved.
Titanium is licensed under the Apache Public License (Version 2).