diff --git a/src/dropHandler.js b/src/dropHandler.js new file mode 100644 index 00000000..96b62302 --- /dev/null +++ b/src/dropHandler.js @@ -0,0 +1,24 @@ +function dropHandler(ev) { + console.log("File(s) dropped"); + + ev.preventDefault(); + + if (ev.dataTransfer.items) { + [...ev.dataTransfer.items].forEach((item, i) => { + if (item.kind === "file") { + const file = item.getAsFile(); + document.querySelector('.current').src = file.path; + } + }); + } else { + alert('File type unsupported.') + } + } + + + function dragOverHandler(ev) { + console.log("File(s) in drop zone"); + + ev.preventDefault(); + } + \ No newline at end of file diff --git a/src/index.html b/src/index.html index 6ece6c7b..6c105569 100644 --- a/src/index.html +++ b/src/index.html @@ -6,11 +6,12 @@ + - +
loading...