Skip to content

Commit

Permalink
feat : optimize Banner Performance with Lazy Loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Manancode committed Oct 30, 2024
1 parent 85c9a35 commit caaf607
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions components/campaigns/AnnouncementHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export default function AnnouncementHero({ className = '', small = false }: IAnn
)}
<div className='relative flex w-5/6 flex-col items-center justify-center gap-2'>
<div className='relative flex min-h-72 w-full items-center justify-center overflow-hidden lg:h-[17rem] lg:w-[38rem]'>
{visibleBanners.map((banner, index) => (
{visibleBanners.map((banner, index) => {
// Only render active banner and immediate neighbors
const isVisible = Math.abs(index - (activeIndex % numberOfVisibleBanners)) <= 1;
if (!isVisible) return null;
return(
<Banner
key={index}
title={banner.title}
Expand All @@ -76,7 +80,8 @@ export default function AnnouncementHero({ className = '', small = false }: IAnn
className={className}
small={small}
/>
))}
);
})}
</div>
<div className='m-auto flex justify-center'>
{visibleBanners.map((banner, index) => (
Expand Down

0 comments on commit caaf607

Please sign in to comment.