Skip to content

Instantly share code, notes, and snippets.

@gbaldera
Forked from pec1985/app.js
Created July 30, 2013 17:06
Show Gist options
  • Save gbaldera/6114839 to your computer and use it in GitHub Desktop.
Save gbaldera/6114839 to your computer and use it in GitHub Desktop.
var win = Ti.UI.createWindow();
var images = [];
for(var i = 1; i < 100; i++){
// Assuming all the images are called image1.jpg, image2.jpeg, etc...
images.push('/images/image'+i+'.jpg');
}
var gallery = Gallery(images,0);
win.add(gallery.view);
win.open();
function Zoomable(image) {
var scroll = Ti.UI.createScrollView({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
contentWidth: 'auto',
contentHeight: 'auto',
});
var image = Ti.UI.createImageView({
image: image,
width: Ti.UI.SIZE,
height: Ti.UI.SIZE
});
function onLoad() {
image.removeEventListener('load', onLoad);
var ratio = 0,
width = image.rect.width,
height = image.rect.height;
if(width > height) {
ratio = scroll.rect.width / width;
} else {
ratio = scroll.rect.height / height
}
scroll.minZoomScale = ratio;
scroll.zoomScale = ratio;
image.image = image.image;
}
image.addEventListener('load', onLoad);
scroll.add(image);
return {
view: scroll,
image: image
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment