// create another variable , self
var self = Ti.UI.currentWindow;
var view = Ti.UI.createView();
var imageView = Ti.UI.createImageView(
{
image:'/images/screenshot_AVD.png',
enableZoomControls:false,
width:'auto',
height:'auto'
}
);
imageView.addEventListener("load", function(e){
Ti.API.info("image loaded");
Ti.API.info("size: " + imageView.size.width + ", " + imageView.size.height);
}
);
var scrollView = Ti.UI.createScrollView(
{
//contentWidth: 'auto',
//contentHeight: 'auto',
showVerticalScrollIndicator: true,
showHorizontalScrollIndicator: true,
height: '80%',
width: '80%'
//zoomScale:2,
//minZoomScale:1,
//maxZoomScale:7
}
);
var originalWidth = -1;
var originalHeight = -1;
var scale = 1;
scrollView.addEventListener("touchend", function(e){
Ti.API.info("touchend");
originalWidth *= scale;
originalHeight *= scale;
});
scrollView.addEventListener("pinch", function(e){
Ti.API.info("pinch: " + e.scale);
//scrollView.zoomScale = e.scale;
if(originalWidth < 0){
Ti.API.info("size: " + imageView.size.width + ", " + imageView.size.height);
originalWidth = imageView.size.width;
originalHeight = imageView.size.height;
}
imageView.width = e.scale * originalWidth;
imageView.height = e.scale * originalHeight;
scale = e.scale;
//scrollView.contentWidth *= e.scale ;
//scrollView.contentHeight *= e.scale;
})
scrollView.add(imageView);
self.add(scrollView);
not fool proof for zooming. scrollbar not showing properly
may be better to use the transform matrix, eg. scale