Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(carousel-image): preload images #68

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions src/components/ImageCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,31 @@ export default function ImageCarousel({ images, width, height }: ImageCarouselPr
});

return (
<div
className={`transition-opacity duration-500 ease-in-out ${
isTransitioning ? 'opacity-0' : 'opacity-100'
}`}
>
<Image
src={images[currentImageIndex].src}
alt={images[currentImageIndex].alt}
width={width}
height={height}
className="h-full w-full object-cover"
/>
</div>
<>
{images.map((image, i) => (
<Image
key={i}
src={image.src}
alt={image.alt}
width={width}
height={height}
className="hidden"
priority
/>
))}
<div
className={`transition-opacity duration-500 ease-in-out ${
isTransitioning ? 'opacity-0' : 'opacity-100'
}`}
>
<Image
src={images[currentImageIndex].src}
alt={images[currentImageIndex].alt}
width={width}
height={height}
className="h-full w-full object-cover"
/>
</div>
</>
);
}
Loading