Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created September 18, 2012 21:57
Show Gist options
  • Save chrisallick/3746185 to your computer and use it in GitHub Desktop.
Save chrisallick/3746185 to your computer and use it in GitHub Desktop.
check x and y to handle leave event properly drag and drop html5
$('#draganddrop-wrapper').hide();
$(document).bind('dragenter', function(event) {
$('#draganddrop-wrapper').fadeIn(500);
return false;
});
$("#draganddrop-wrapper").bind('dragover', function(event) {
return false;
}).bind('dragleave', function(event) {
if( window.event.pageX == 0 || window.event.pageY == 0 ) {
$(this).fadeOut(500);
return false;
}
}).bind('drop', function(event) {
handleDrop(event);
$(this).fadeOut(500);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment