I am developing a drag-and-drop system for image files and I have noticed that the dragenter
event is also executed on the selected text drag.
$(document).on("dragenter", "#element", function(event){
event.preventDefault();
// Check if we are dragging text
if(is_text){ // <- HERE
console.log("dragging text!");
}else{
console.log("dragging file!");
}
});
I want to detect that the dragged object is not text, so the previous console.log
would not run if it were.
UPDATE AND SOLUTION:
var dragging_text = false;
$(window).on("dragstart", function(event){
dragging_text = true;
console.log("dragstart");
});
$(document).on("dragenter", "#element", function(event){
event.preventDefault();
if(dragging_text){
console.log("NO, dragging text!");
}else{
console.log("OK, dragging file!");
}
});