From fd07adccbbabb65ecdf9bf93a3ed9f7753079a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Wed, 25 Sep 2024 14:08:46 +0200 Subject: [PATCH 1/2] Not opening imagelightbox if it's already open --- src/lib/State.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/State.ts b/src/lib/State.ts index 2a580c82..30dbce89 100644 --- a/src/lib/State.ts +++ b/src/lib/State.ts @@ -241,6 +241,9 @@ export function State( } function open(index: number, skipHistory = false): void { + if (currentImage !== null) { + return; + } addContainerToDOM(options.animationSpeed, options.quitOnDocClick, close); if (options.activity) { addActivityIndicatorToDOM(); From 764a7b3efb5b2737485d119b429f6f668000480b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20D=C4=9Bdi=C4=8D?= Date: Wed, 25 Sep 2024 22:05:29 +0200 Subject: [PATCH 2/2] Fixed race condition when scrolling throught lightbox quickly --- src/lib/State.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/State.ts b/src/lib/State.ts index 30dbce89..2bfb035a 100644 --- a/src/lib/State.ts +++ b/src/lib/State.ts @@ -140,10 +140,10 @@ export function State( transitionDirection: TransitionDirection, ): void { const newImageView = ImageView(targetImages[newIndex], options, videoCache); + currentImage = newIndex; + currentImageView = newImageView; newImageView.startLoading( () => { - currentImage = newIndex; - currentImageView = newImageView; addNewImage(transitionDirection); }, () => {