Browse Source

fix: more minor fixes

Sv443 1 year ago
parent
commit
abdf192856
2 changed files with 6 additions and 4 deletions
  1. 5 3
      src/features/layout.ts
  2. 1 1
      src/siteEvents.ts

+ 5 - 3
src/features/layout.ts

@@ -471,6 +471,8 @@ export async function initThumbnailOverlay() {
     }
   };
 
+  window.addEventListener("bytm:ready", updateOverlayVisibility, { once: true });
+
   const applyThumbUrl = async (watchId: string) => {
     const thumbUrl = await getBestThumbnailUrl(watchId);
     if(thumbUrl) {
@@ -592,16 +594,17 @@ export async function initHideCursorOnIdle() {
       /** Timer after which the cursor is hidden */
       let cursorHideTimer: ReturnType<typeof setTimeout>;
       /** Timer for the opacity transition while switching to the hidden state */
-      let hideTransTimer: ReturnType<typeof setTimeout>;
+      let hideTransTimer: ReturnType<typeof setTimeout> | undefined;
 
       const hide = () => {
         if(vidContainer.classList.contains("bytm-cursor-hidden"))
           return;
-        overlayElem.style.opacity = "0 !important";
+        overlayElem.style.opacity = ".000001 !important";
         hideTransTimer = setTimeout(() => {
           overlayElem.style.display = "none";
           vidContainer.style.cursor = "none";
           vidContainer.classList.add("bytm-cursor-hidden");
+          hideTransTimer = undefined;
         }, 200);
       };
 
@@ -620,7 +623,6 @@ export async function initHideCursorOnIdle() {
 
       const onMove = () => {
         cursorHideTimer && clearTimeout(cursorHideTimer);
-        hideTransTimer && clearTimeout(hideTransTimer);
         show();
         cursorHideTimerCb();
       };

+ 1 - 1
src/siteEvents.ts

@@ -141,7 +141,7 @@ export async function initSiteEvents() {
       }
       setTimeout(checkWatchId, 200);
     };
-    window.addEventListener("bytm:ready", () => checkWatchId(), { once: true });
+    window.addEventListener("bytm:ready", checkWatchId, { once: true });
   }
   catch(err) {
     error("Couldn't initialize SiteEvents observers due to an error:\n", err);