From 4f0392554bb186af7ef6a37899530b2220e2e952 Mon Sep 17 00:00:00 2001 From: vineyardbovines Date: Thu, 4 Jun 2026 14:33:53 -0400 Subject: [PATCH] Gate lightbox neighbor mounts on open-animation completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Window stays at 0 (active image only) until openProgress reaches 1, then expands to ±1. Reuses the same shared-value gate as the existing orientation-unlock reaction so the heaviest decode work happens after the open transition rather than during it. --- src/components/Lightbox/pager/ImagePager.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/Lightbox/pager/ImagePager.tsx b/src/components/Lightbox/pager/ImagePager.tsx index e4c49aebb5..2b9a135a17 100644 --- a/src/components/Lightbox/pager/ImagePager.tsx +++ b/src/components/Lightbox/pager/ImagePager.tsx @@ -249,9 +249,22 @@ function ImageView({ const [isDragging, setIsDragging] = useState(false) const [showControls, setShowControls] = useState(true) const [isAltExpanded, setIsAltExpanded] = useState(false) + const [hasFullyOpened, setHasFullyOpened] = useState(false) const dismissSwipeTranslateY = useSharedValue(0) const isFlyingAway = useSharedValue(false) + // Hold the neighbor window at 0 until the open animation completes, so we + // only decode the active image during the most memory-constrained moment. + // Mirrors the orientation-unlock gate below. + useAnimatedReaction( + () => openProgress.get() === 1, + isOpen => { + if (isOpen) { + runOnJS(setHasFullyOpened)(true) + } + }, + ) + const containerStyle = useAnimatedStyle(() => { if (openProgress.get() < 1) { return { @@ -415,7 +428,7 @@ function ImageView({ style={styles.pager}> {images.map((imageSrc, i) => ( - {Math.abs(i - imageIndex) <= 1 ? ( + {Math.abs(i - imageIndex) <= (hasFullyOpened ? 1 : 0) ? (