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) ? (