Skip to content

Commit

Permalink
refactor: migrate into individual .js files
Browse files Browse the repository at this point in the history
  • Loading branch information
khajornritdacha committed Dec 5, 2023
1 parent f3aae30 commit 5d3bd5e
Show file tree
Hide file tree
Showing 3 changed files with 444 additions and 491 deletions.
25 changes: 25 additions & 0 deletions dragdrop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const dropContainer = document.getElementById("dropcontainer");
const fileInput = document.getElementById("input-file");

dropContainer.addEventListener(
"dragover",
(e) => {
// prevent default to allow drop
e.preventDefault();
},
false
);

dropContainer.addEventListener("dragenter", () => {
dropContainer.classList.add("drag-active");
});

dropContainer.addEventListener("dragleave", () => {
dropContainer.classList.remove("drag-active");
});

dropContainer.addEventListener("drop", (e) => {
e.preventDefault();
dropContainer.classList.remove("drag-active");
fileInput.files = e.dataTransfer.files;
});
Loading

0 comments on commit 5d3bd5e

Please sign in to comment.