Skip to content

Instantly share code, notes, and snippets.

@parrfolio
Created October 22, 2012 04:10
Show Gist options
  • Save parrfolio/3929603 to your computer and use it in GitHub Desktop.
Save parrfolio/3929603 to your computer and use it in GitHub Desktop.
Touch Resizing and Rotating
var width = 100,
height = 200,
rotation = 0;
node.addEventListener("gesturechange", function(event){
var style = event.target.style;
// scale and rotation are relative values,
// so we wait to change our variables until the gesture ends
style.width = (width * event.scale) + "px";
style.height = (height * event.scale) + "px";
style.webkitTransform = "rotate(" + ((rotation
+ event.rotation) % 360) + "deg)";
}, false);
node.addEventListener("gestureend", function(event){
// Update the values for the next time a gesture happens
width *= event.scale;
height *= event.scale;
rotation = (rotation + event.rotation) % 360;
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment