I’m building a drag and drop method, using query
-onmousedown
leading to -onmousemove (drag) then -onmouseup (unbinds onmousemove)
the problem is, browser defaults begin highlighting onmousemove, which flies all over the page and cancels the event, rendering it unusable. any idea how to prevent highlighting, for preventDefault seems not to be working. here is my code (yes its very sloppy, sorry!)
$(".middleRow").mousedown(function(){
calculateSelection();
$('body').append('<div class="messageDrag" style="display:block">'+numSelected+'<div style="font-size: 18px">messages</div></div>');
$(document).mouseup(function(){
$('.messageDrag').fadeOut(500);
setTimeout(function(){
$('.messageDrag').remove();
}, 500);
$(document).unbind();
})
$(document).mousemove(function(e){
e.preventDefault();
var x = e.pageX;
var y = e.pageY;
$(".messageDrag").css("left", x-49);
$(".messageDrag").css("top", y-49);
});
});
You could disable highlighting using css
another way of doing this is to clear selection on drop event, as so:
So you would call
clearSelection()on drop event (after the drag is finished)