Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispader committed Jan 24, 2024
1 parent 2a2f007 commit 33dea64
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/components/Lightbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ function Lightbox({
[contentSize, setContentSize],
);

const isItemActive = index === activeIndex;
const [isActive, setActive] = useState(isItemActive);

// Enables/disables the lightbox based on the number of concurrent lightboxes
// On higher-end devices, we can show render lightboxes at the same time,
// while on lower-end devices we want to only render the active carousel item as a lightbox
Expand Down Expand Up @@ -129,21 +126,11 @@ function Lightbox({
// because it's only going to be rendered after the fallback image is hidden.
const shouldShowLightbox = isLightboxImageLoaded && (!hasSiblingCarouselItems || !isFallbackVisible);

const isActive = index === activeIndex;
const isFallbackStillLoading = isFallbackVisible && !isFallbackImageLoaded;
const isLightboxStillLoading = isLightboxVisible && !isLightboxImageLoaded;
const isLoading = isActive && (isCanvasLoading || isFallbackStillLoading || isLightboxStillLoading);

// We delay setting a page to active state by a (few) millisecond(s),
// to prevent the image transformer from flashing while still rendering
// Instead, we show the fallback image while the image transformer is loading the image
useEffect(() => {
if (isItemActive) {
setTimeout(() => setActive(true), 1);
} else {
setActive(false);
}
}, [isItemActive]);

// Resets the lightbox when it becomes inactive
useEffect(() => {
if (isLightboxVisible) {
Expand Down

0 comments on commit 33dea64

Please sign in to comment.