Fix slideshow autoplaying when on another tab (#2563)

This commit is contained in:
WithoutPants
2022-05-06 12:23:06 +10:00
committed by GitHub
parent 73ded0d97d
commit 9ca3874707
3 changed files with 20 additions and 14 deletions

View File

@@ -279,8 +279,11 @@ export const LightboxComponent: React.FC<IProps> = ({
}
}, [slideshowInterval, slideshowDelay]);
usePageVisibility(() => {
toggleSlideshow();
// stop slideshow when the page is hidden
usePageVisibility((hidden: boolean) => {
if (hidden) {
setSlideshowInterval(null);
}
});
const close = useCallback(() => {