Skip to content

Commit 6a7cf1a

Browse files
committed
Fix merge conflict with #6354
1 parent da6b55f commit 6a7cf1a

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

ui/v2.5/src/hooks/Lightbox/Lightbox.tsx

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ export const LightboxComponent: React.FC<IProps> = ({
229229
const [index, setIndex] = useState<number | null>(null);
230230
const [movingLeft, setMovingLeft] = useState(false);
231231
const oldIndex = useRef<number | null>(null);
232-
const [transition, setTransition] = useState<string | null>(null);
233232
const [isSwitchingPage, setIsSwitchingPage] = useState(true);
234233
const [isFullscreen, setFullscreen] = useState(false);
235234
const [showOptions, setShowOptions] = useState(false);
@@ -312,6 +311,11 @@ export const LightboxComponent: React.FC<IProps> = ({
312311
);
313312

314313
const disableAnimation = config?.interface.imageLightbox.disableAnimation;
314+
const defaultTransition = disableAnimation ? CLASSNAME_INSTANT : null;
315+
316+
const [transition, setTransition] = useState<string | null>(
317+
defaultTransition
318+
);
315319

316320
function setSlideshowDelay(v: number) {
317321
setLightboxSettings({ slideshowDelay: v });
@@ -343,7 +347,10 @@ export const LightboxComponent: React.FC<IProps> = ({
343347
}
344348
}, [isSwitchingPage, images, index]);
345349

346-
const restoreTransition = useDebounce(() => setTransition(null), 400);
350+
const restoreTransition = useDebounce(
351+
() => setTransition(defaultTransition),
352+
400
353+
);
347354

348355
const overrideTransition = useCallback(
349356
(t: string) => {
@@ -453,10 +460,6 @@ export const LightboxComponent: React.FC<IProps> = ({
453460
(isUserAction = true) => {
454461
if (isSwitchingPage || index === -1) return;
455462

456-
if (disableAnimation) {
457-
setInstant();
458-
}
459-
460463
setShowChapters(false);
461464
setMovingLeft(true);
462465

@@ -474,25 +477,13 @@ export const LightboxComponent: React.FC<IProps> = ({
474477
resetIntervalCallback.current();
475478
}
476479
},
477-
[
478-
images,
479-
pageCallback,
480-
isSwitchingPage,
481-
resetIntervalCallback,
482-
index,
483-
disableAnimation,
484-
setInstant,
485-
]
480+
[images, pageCallback, isSwitchingPage, resetIntervalCallback, index]
486481
);
487482

488483
const handleRight = useCallback(
489484
(isUserAction = true) => {
490485
if (isSwitchingPage) return;
491486

492-
if (disableAnimation) {
493-
setInstant();
494-
}
495-
496487
setMovingLeft(false);
497488
setShowChapters(false);
498489

@@ -517,8 +508,6 @@ export const LightboxComponent: React.FC<IProps> = ({
517508
isSwitchingPage,
518509
resetIntervalCallback,
519510
index,
520-
disableAnimation,
521-
setInstant,
522511
]
523512
);
524513

0 commit comments

Comments
 (0)