From 5e64e9ea1b1e5584e842315c0754a6136a79d62c Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Mon, 5 Aug 2024 21:31:47 +0200 Subject: [PATCH] add a little timeout to the delayed cw thing it seems like sometimes the load handlers are processed before the image is actually switched --- script/single.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/single.ts b/script/single.ts index 116c83e..21e6f8c 100644 --- a/script/single.ts +++ b/script/single.ts @@ -27,7 +27,8 @@ function setImage(id: string, src: string, href: string, cw: string): void { if (curCw && !coverNew) { // keep old cover until load - mainimg.addEventListener('load', () => openCW(null, curCw), {once: true}); + function removeCover() { setTimeout(() => openCW(null, curCw!), 100); } + mainimg.addEventListener('load', removeCover, {once: true}); } else if (coverNew) { // place new cover const newCw =