Overlay reorganised. Volume now stored in a global variable.
This commit is contained in:
parent
bc2d2f6e74
commit
72d6e835bb
@ -4,6 +4,7 @@ const image_formats = ["jpg", "jpeg", "gif", "png", "bmp", "webp"];
|
|||||||
|
|
||||||
const overlay = document.getElementById("overlay");
|
const overlay = document.getElementById("overlay");
|
||||||
let scale = 1;
|
let scale = 1;
|
||||||
|
let g_volume = 1.0;
|
||||||
|
|
||||||
function mousescroll(e) {
|
function mousescroll(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -11,18 +12,33 @@ function mousescroll(e) {
|
|||||||
e.target.style.transform = `scale(${scale})`;
|
e.target.style.transform = `scale(${scale})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onvolumechange(e) {
|
||||||
|
g_volume = e.target.volume;
|
||||||
|
console.log("new ", e);
|
||||||
|
}
|
||||||
|
|
||||||
const ext_filter = (ext, pathname) => pathname.toLowerCase().endsWith(ext);
|
const ext_filter = (ext, pathname) => pathname.toLowerCase().endsWith(ext);
|
||||||
|
|
||||||
function to_overlay(eltyp, pathname) {
|
function to_overlay(eltyp, pathname) {
|
||||||
|
const div = document.createElement("div");
|
||||||
const el = document.createElement(eltyp);
|
const el = document.createElement(eltyp);
|
||||||
|
const el_label = document.createElement("span");
|
||||||
|
el_label.textContent = decodeURI(pathname.substr(pathname.lastIndexOf("/") + 1));
|
||||||
if (eltyp !== "audio") el.addEventListener('wheel', mousescroll);
|
if (eltyp !== "audio") el.addEventListener('wheel', mousescroll);
|
||||||
if (eltyp !== "img") el.autoplay = el.controls = true;
|
if (eltyp !== "img") {
|
||||||
|
el.autoplay = el.controls = true;
|
||||||
|
el.addEventListener("volumechange", onvolumechange);
|
||||||
|
el.volume = g_volume;
|
||||||
|
}
|
||||||
el.src = pathname;
|
el.src = pathname;
|
||||||
overlay.appendChild(el);
|
overlay.appendChild(el);
|
||||||
|
overlay.appendChild(el_label);
|
||||||
|
// overlay.appendChild(div);
|
||||||
overlay.style.visibility = "visible";
|
overlay.style.visibility = "visible";
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("overlay").addEventListener("click", e => {
|
document.getElementById("overlay").addEventListener("click", e => {
|
||||||
|
e.target.firstChild.remove();
|
||||||
e.target.firstChild.remove();
|
e.target.firstChild.remove();
|
||||||
e.target.style.visibility = "hidden";
|
e.target.style.visibility = "hidden";
|
||||||
scale = 1;
|
scale = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user