Skip to content

Commit

Permalink
Add images via drop
Browse files Browse the repository at this point in the history
  • Loading branch information
agatemosu committed Jul 24, 2024
1 parent 01daf89 commit aa1a1f3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ document.addEventListener(
},
);

document.addEventListener("drop", (e) => {
e.preventDefault();
uploadImages(e.dataTransfer.files);
});

document.addEventListener("dragover", (e) => {
e.preventDefault();
});

function createColorPicker(colorPicker, tierLabel, defaultColor) {
const pickr = Pickr.create({
el: colorPicker,
Expand Down Expand Up @@ -187,6 +196,10 @@ function selectImages() {

function uploadImages(files) {
for (const file of files) {
if (file.type.split("/")[0] !== "image") {
continue;
}

const image = new Image();
image.src = URL.createObjectURL(file);

Expand Down

0 comments on commit aa1a1f3

Please sign in to comment.