fix: home page carousel causing scroll on item change and fix other performance issues
This commit is contained in:
5 files changed
+120
-94
No files matched your search
@@ -5,37 +5,45 @@ type CarouselTickersProps = {
|
||||
imageUrl?: string;
|
||||
itemName: string;
|
||||
itemYear: string;
|
||||
onClick: () => void;
|
||||
onTickerClick: (index: number) => void;
|
||||
index: number;
|
||||
isActive: boolean;
|
||||
};
|
||||
|
||||
const CarouselTickers = ({
|
||||
imageUrl,
|
||||
itemName,
|
||||
itemYear,
|
||||
onClick,
|
||||
isActive,
|
||||
}: CarouselTickersProps) => {
|
||||
return (
|
||||
<div
|
||||
className={`carousel-ticker${isActive ? " active" : ""}`}
|
||||
onClick={onClick}
|
||||
>
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt={itemName}
|
||||
className="carousel-ticker-image"
|
||||
// style={{ width: "5em", height: "100%", objectFit: "cover" }}
|
||||
/>
|
||||
<div>
|
||||
<Typography variant="subtitle1" className="carousel-ticker-title">
|
||||
{itemName}
|
||||
</Typography>
|
||||
<Typography variant="caption" className="carousel-ticker-year">
|
||||
{itemYear}
|
||||
</Typography>
|
||||
const CarouselTickers = React.memo(
|
||||
({
|
||||
imageUrl,
|
||||
itemName,
|
||||
itemYear,
|
||||
onTickerClick,
|
||||
index,
|
||||
isActive,
|
||||
}: CarouselTickersProps) => {
|
||||
const handleClick = React.useCallback(() => {
|
||||
onTickerClick(index);
|
||||
}, [index, onTickerClick]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`carousel-ticker${isActive ? " active" : ""}`}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<img
|
||||
src={imageUrl}
|
||||
alt={itemName}
|
||||
className="carousel-ticker-image"
|
||||
// style={{ width: "5em", height: "100%", objectFit: "cover" }}
|
||||
/>
|
||||
<div>
|
||||
<Typography variant="subtitle1" className="carousel-ticker-title">
|
||||
{itemName}
|
||||
</Typography>
|
||||
<Typography variant="caption" className="carousel-ticker-year">
|
||||
{itemYear}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
);
|
||||
},
|
||||
);
|
||||
export default CarouselTickers;
|
||||
Reference in new issue
Block a user