Added proper whole-page drag-and-drop support

This commit is contained in:
2021-05-03 12:08:13 +02:00
parent c3a983b2aa
commit 1de6400210
5 changed files with 85 additions and 17 deletions

View File

@@ -47,6 +47,7 @@ function getAndSetDominantColor() {
dc.style.backgroundColor = hexCol;
dc.title = hexCol;
img.style.borderColor = hexCol;
copyToClipboard(hexCol);
}
function getAndSetPalette() {
@@ -99,8 +100,24 @@ function rgbToHex(r, g, b) {
//##########################################################################################################################
const custom = document.getElementById("custom");
const file = document.getElementById("file");
file.addEventListener("change", function () {
document.getElementById('img').src = window.URL.createObjectURL(this.files[0]);
renew();
});
const body = document.getElementsByTagName("body")[0];
body.addEventListener("dragover", function () {
file.classList.add("show");
});
["dragleave", "drop"].forEach(function (a) {
file.addEventListener(a, function () {
file.classList.remove("show");
});
});
const custom = document.getElementById("custom");
custom.addEventListener("keyup", function () {
if (custom.value.length == 7) {
document.getElementById("img").style.borderColor = custom.value;