Add callback to fileUploading drag-n-drop

This commit is contained in:
cyber-dream 2023-05-04 22:49:42 +03:00
parent b496ce2ab2
commit ccc24b93ad

View File

@ -6,7 +6,7 @@ class FileView{
* @param {Function} doubleClickCallback
* @param {Function} rightClickCallback
*/
constructor(fileViewElem, doubleClickCallback, rightClickCallback){
constructor(fileViewElem, doubleClickCallback, rightClickCallback, fileUploadCallback){
//TODO check all params
this.parentElem = fileViewElem
@ -33,6 +33,23 @@ class FileView{
this.Select([event.target])
rightClickCallback(event)
})
if (fileUploadCallback !== undefined) {
fileViewElem.addEventListener('dragenter', function(event) {
// console.log("start")
})
fileViewElem.addEventListener('dragover', function(event) {
event.preventDefault();
// console.log("over")
})
fileViewElem.addEventListener("drop", (event) => {
event.preventDefault();
// console.log(event.dataTransfer.items[0])
fileUploadCallback(event.dataTransfer.items)
})
}
}
/**