TiTouchGallery is a native Android module, which allows you to create a gallery view, with zoom (pinch / double tap) and pan support, in your Titanium Android app.
##Copyright
This module is a fork of the android gallery widget from Dreddik with some changes.
Thanks Dreddik for share this.
##Download
Grab the lastest build from the dist folder
Simply add the following lines to your tiapp.xml
file:
<modules>
<module platform="android">com.gbaldera.titouchgallery</module>
</modules>
To access this module from JavaScript, you would do the following:
var titouchgallery = require("com.gbaldera.titouchgallery");
The titouchgallery variable is a reference to the Module object.
####images : String[]
Array of images to display in the gallery (Only Remote images are supported for now)
####currentPage : Number
index of the active page
List of methods supported in this module:
var proxy = titouchgallery.createTouchGallery({
images: [
"http://cs407831.userapi.com/v407831207/18f6/jBaVZFDhXRA.jpg",
"http://cs407831.userapi.com/v4078f31207/18fe/4Tz8av5Hlvo.jpg",
"http://cs407831.userapi.com/v407831207/1906/oxoP6URjFtA.jpg",
"http://cs407831.userapi.com/v407831207/190e/2Sz9A774hUc.jpg",
"http://cs407831.userapi.com/v407831207/1916/Ua52RjnKqjk.jpg",
"http://cs407831.userapi.com/v407831207/191e/QEQE83Ok0lQ.jpg"
],
currentPage:2
});
Get the array with the images displayed in the gallery.
None
Set the array with the images to be displayed in the gallery.
- Images [array]: Images to be displayed in the gallery
Adds a new image to the gallery
- Image [string]: Image URL to be added to the gallery
Removes the specified image from the gallery
- Image [string]: Image URL to be removed from the gallery
Get the total number of images in the gallery.
None
Sets the current page to the next consecutive page in images.
None
Sets the current page to the previous consecutive page in images.
None
Gets the value of the currentPage property.
None
Sets the value of the currentPage property.
- currentPage [number]: New value for the currentPage property
Fired when the device detects a single tap against the view.
- currentPage : Index of the image.
- url : URL of the image.
- source : Source object that fired the event.
- type : String Name of the event fired.
- x : NumberX coordinate of the event from the source view's coordinate system.
- y : NumberY coordinate of the event from the source view's coordinate system.
Fired when the device detects a long press against this view.
- currentPage : Index of the image.
- url : URL of the image.
- source : Source object that fired the event.
- type : String Name of the event fired.
- x : NumberX coordinate of the event from the source view's coordinate system.
- y : NumberY coordinate of the event from the source view's coordinate system.
Fired when the gallery changed the page
- currentPage : Index of the image.
- url : URL of the image.
var win = Ti.UI.createWindow({
backgroundColor:'#000'
});
var titouchgallery = require('com.gbaldera.titouchgallery');
if (Ti.Platform.name == "android") {
var proxy = titouchgallery.createTouchGallery({
images: [
"http://cs407831.userapi.com/v407831207/18f6/jBaVZFDhXRA.jpg",
"http://cs407831.userapi.com/v4078f31207/18fe/4Tz8av5Hlvo.jpg",
"http://cs407831.userapi.com/v407831207/1906/oxoP6URjFtA.jpg",
"http://cs407831.userapi.com/v407831207/190e/2Sz9A774hUc.jpg",
"http://cs407831.userapi.com/v407831207/1916/Ua52RjnKqjk.jpg",
"http://cs407831.userapi.com/v407831207/191e/QEQE83Ok0lQ.jpg"
]
});
proxy.addEventListener("scroll", function(e){
Ti.API.debug("Scroll event fired: " + JSON.stringify(e));
});
proxy.addEventListener("singletap", function(e){
alert("Page: " + e.currentPage);
Ti.API.debug("SingleTap event fired: " + JSON.stringify(e));
});
proxy.addEventListener("longpress", function(e){
alert("Page: " + e.currentPage);
Ti.API.debug("LongPress event fired: " + JSON.stringify(e));
});
win.add(proxy);
}
win.open();
- Add support for local images.
- Cache remote images.
- 1.1:
- Fixed single tap and added long press events
- 1.0: Initial version
Gustavo Rodriguez Baldera
It's open source and it's under DBAD License