Skip to content

Instantly share code, notes, and snippets.

@parrfolio
Created October 22, 2012 04:09
Show Gist options
  • Save parrfolio/3929589 to your computer and use it in GitHub Desktop.
Save parrfolio/3929589 to your computer and use it in GitHub Desktop.
Basic Touch Drag and Drop
node.addEventListener("touchmove", function(event){
// Only deal with one finger
if(event.touches.length == 1){
// Get the information for finger #1
var touch = event.touches[0],
// Find the style object for the node the drag started from
style = touch.target.style;
// Position the element under the touch point
style.position = "absolute";
style.left = touch.pageX + "px";
style.top = touch.pageY + "px";
}
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment