Skip to content

Instantly share code, notes, and snippets.

@DrewDahlman
Created July 9, 2012 23:34
Show Gist options
  • Save DrewDahlman/3079783 to your computer and use it in GitHub Desktop.
Save DrewDahlman/3079783 to your computer and use it in GitHub Desktop.
$this.bind('touchmove', function(event){
var touchDiffY = event.originalEvent.changedTouches[0].screenY - data.startY;
var x = data.startX - event.originalEvent.touches[0].pageX;
var y = data.startY = touchDiffY;
var r = Math.atan2(y,x);
var angle = Math.round(r*180/Math.PI);
//angle = 360 - Math.abs(angle);
if(angle < 0 )
angle = 360 - Math.abs(angle);
console.log(angle);
if((angle > 45) && (angle < 135)){
}
else if((angle < 45) && (angle > 135)){
}
else {
event.preventDefault();
}
data.distanceX = event.originalEvent.touches[0].pageX - data.startX;
$wrapper.css({'left':(data.distanceX+data.newPos)+'px'});
//console.log(data.newPos);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment