From 95f4b814bf7046c9beef12fc880642baeb5edab4 Mon Sep 17 00:00:00 2001 From: Luther Tchofo Safo Date: Fri, 13 Sep 2024 13:39:07 +0200 Subject: [PATCH] Testing interruptability in production. --- .../carousel-part-cleaned/carousel.tsx | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/(pages)/carousel-part-cleaned/carousel.tsx b/app/(pages)/carousel-part-cleaned/carousel.tsx index 372c697..a045c00 100644 --- a/app/(pages)/carousel-part-cleaned/carousel.tsx +++ b/app/(pages)/carousel-part-cleaned/carousel.tsx @@ -156,15 +156,17 @@ export default function Carousel({ images }: { images: string[] }) { let objectFittingScrollHeight = useMotionValue(height); useEffect(() => { - const image = document.getElementById( - `${IMAGEID + index}`, - ) as HTMLImageElement; - const imageDecoding = async () => await image.decode(); - imageDecoding().then(() => { - objectFittingScrollHeight.set( - document.getElementById(`${IMAGEID + index}`)!.clientHeight, - ); - }); + if (objectFitting === "scroll") { + const image = document.getElementById( + `${IMAGEID + index}`, + ) as HTMLImageElement; + const imageDecoding = async () => await image.decode(); + imageDecoding().then(() => { + objectFittingScrollHeight.set( + document.getElementById(`${IMAGEID + index}`)!.clientHeight, + ); + }); + } }, [index, objectFitting, width, images]); /* NEXT UP WOULD BE: