From 8e5e277ee45778521e47dc646b4e2e2ce93f6870 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 24 Jun 2021 12:22:25 +1000 Subject: [PATCH] don't wait for images before revealing Currently there's a nasty blink when revealing the answer if the answer has images on it, as the entire card is hidden, and not shown again until the images have loaded. This patch removes the wait, so text should appear more quickly, but it will mean the images may pop in. We still wait for images before scrolling, to avoid a scroll to the wrong location. There's plenty of scope to improve this further - preloading images, rendering MathJax in advance, etc, but those changes will need to wait for now. #1120 has some related discussion. --- qt/aqt/data/web/js/reviewer.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/qt/aqt/data/web/js/reviewer.ts b/qt/aqt/data/web/js/reviewer.ts index c56b07638..d28c6e6b1 100644 --- a/qt/aqt/data/web/js/reviewer.ts +++ b/qt/aqt/data/web/js/reviewer.ts @@ -95,9 +95,6 @@ async function _updateQA( }) .catch(renderError("MathJax")); - // defer display for up to 100ms to allow images to load - await Promise.race([allImagesLoaded(), new Promise((r) => setTimeout(r, 100))]); - // and reveal card when processing is done qa.style.opacity = "1"; await _runHook(onShownHook); @@ -136,8 +133,7 @@ function _showAnswer(a: string, bodyclass: string): void { document.body.className = bodyclass; } - // avoid scrolling to the answer until images load, even if it - // takes more than 100ms + // avoid scrolling to the answer until images load allImagesLoaded().then(scrollToAnswer); }, function () {}