From 8728784c02d4c3d31df05e09239cdff6cec08856 Mon Sep 17 00:00:00 2001 From: MiepHD <63968466+MiepHD@users.noreply.github.com> Date: Mon, 9 Jan 2023 18:16:33 +0100 Subject: [PATCH] Fixed running before `#main-panel` exists --- plugins/video-toggle/button-switcher.css | 1 - plugins/video-toggle/front.js | 30 ++++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/plugins/video-toggle/button-switcher.css b/plugins/video-toggle/button-switcher.css index 048d1b6a1..3bae2fc60 100644 --- a/plugins/video-toggle/button-switcher.css +++ b/plugins/video-toggle/button-switcher.css @@ -22,7 +22,6 @@ color: #fff; padding-right: 120px; position: absolute; - left: var(--align); } .video-switch-button:before { diff --git a/plugins/video-toggle/front.js b/plugins/video-toggle/front.js index 07f966c7b..31c1b8f31 100644 --- a/plugins/video-toggle/front.js +++ b/plugins/video-toggle/front.js @@ -31,21 +31,6 @@ module.exports = (_options) => { document.addEventListener("apiLoaded", setup, { once: true, passive: true }); } } - const mainpanel = document.querySelector("#main-panel"); - switch (_options.align) { - case "right": { - mainpanel.style.setProperty("--align", "calc(100% - 240px)"); - return; - } - case "middle": { - mainpanel.style.setProperty("--align", "calc(50% - 120px)"); - return; - } - default: - case "left": { - mainpanel.style.setProperty("--align", "0px"); - } - } }; function setup(e) { @@ -73,6 +58,21 @@ function setup(e) { video.addEventListener('srcChanged', videoStarted); observeThumbnail(); + + switch (options.align) { + case "right": { + switchButtonDiv.style.left = "calc(100% - 240px)"; + return; + } + case "middle": { + switchButtonDiv.style.left = "calc(50% - 120px)"; + return; + } + default: + case "left": { + switchButtonDiv.style.left = "0px"; + } + } } function changeDisplay(showVideo) {