N°3670 Fix drag and drop glitching in Chrome

This commit is contained in:
Stephen Abello
2021-02-19 13:57:01 +01:00
parent 4d8930832e
commit 952280ecc6

View File

@@ -264,6 +264,11 @@ abstract class AbstractAttachmentsRenderer
} }
}); });
$(document).on('drag dragstart dragend dragover dragenter dragleave drop', function(e) {
e.preventDefault();
e.stopPropagation();
})
$(document).bind('dragover', function (e) { $(document).bind('dragover', function (e) {
var bFiles = false; var bFiles = false;
if (e.dataTransfer && e.dataTransfer.types) if (e.dataTransfer && e.dataTransfer.types)
@@ -297,11 +302,20 @@ abstract class AbstractAttachmentsRenderer
window.dropZone.addClass('ibo-drag-in'); window.dropZone.addClass('ibo-drag-in');
}); });
$(document).bind('dragleave dragend drop', function(){ // Counter used to fix chrome firing dragenter/dragleave on each $(document) child it encounter
if(window.dropZone){ window.dropZoneCnt = 0;
$(document).on('dragenter', function(ev) {
ev.preventDefault(); // needed for IE
window.dropZoneCnt++;
});
$(document).bind('dragend dragleave drop', function(event){
window.dropZoneCnt--;
if(window.dropZone && window.dropZoneCnt === 0){
window.dropZone.removeClass('ibo-drag-in'); window.dropZone.removeClass('ibo-drag-in');
window.dropZone = null;
} }
window.dropZone = null;
}); });
// check if the attachments are used by inline images // check if the attachments are used by inline images