Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created October 4, 2011 05:24
Show Gist options
  • Save alanleard/1260961 to your computer and use it in GitHub Desktop.
Save alanleard/1260961 to your computer and use it in GitHub Desktop.
Android Image Rotation within a webview for builtin Pinch zoom
var win = Ti.UI.createWindow();
var web = Ti.UI.createWebView({
html:'<img src="test.jpg"/>',
//url:'http://appcelerator.com'
});
win.add(web);
var button = Ti.UI.createButton({
width:50,
height:50,
bottom:10,
left:10
});
win.add(button);
button.addEventListener('click', function(){
web.animate({opacity:0.5, duration:500});
web.opacity = 0.5;
var start = 0;
web.addEventListener('touchstart', function(e){
start = e.x;
})
web.addEventListener('touchmove', function(e){
var point = ((360/Ti.Platform.displayCaps.platformWidth)*(e.x-start))/2;
Ti.API.info(point);
Ti.API.info(e.x);
var t = Ti.UI.create2DMatrix();
t = t.rotate(point);
web.transform=t;
});
});
win.open();
@alanleard
Copy link
Author

This is a work in progress to make a swipe to rotate functionality. Any suggestions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment