overlay and image loader wip
parent
c08b00b7bc
commit
e8afdfdfc8
@ -1,10 +1,16 @@
|
|||||||
document.querySelector('input[type="file"]').addEventListener("change", function () {
|
window.addEventListener("load", function () {
|
||||||
|
let input = document.querySelector('input[type="file"]');
|
||||||
|
input.addEventListener("change", function () {
|
||||||
|
console.log(this.files);
|
||||||
if (this.files && this.files[0]) {
|
if (this.files && this.files[0]) {
|
||||||
var img = document.querySelector("img");
|
let img = document.querySelector("img");
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
|
img.classList.add("visible");
|
||||||
|
input.classList.add("hidden");
|
||||||
URL.revokeObjectURL(img.src); // no longer needed, free memory
|
URL.revokeObjectURL(img.src); // no longer needed, free memory
|
||||||
};
|
};
|
||||||
|
|
||||||
img.src = URL.createObjectURL(this.files[0]); // set src to blob url
|
img.src = URL.createObjectURL(this.files[0]); // set src to blob url
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue