From ccc24b93ad20272e5f01be09af3c067e79925395 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Thu, 4 May 2023 22:49:42 +0300 Subject: [PATCH] Add callback to fileUploading drag-n-drop --- resources/sys/wde/file-view.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/resources/sys/wde/file-view.js b/resources/sys/wde/file-view.js index d392b07..4e43347 100644 --- a/resources/sys/wde/file-view.js +++ b/resources/sys/wde/file-view.js @@ -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) + }) + } } /**