I am currently working on a horizontal scrolling ImageList using Material UI V5, and I'm looking to create a smoother transition at the edges of the list. I have managed to fade the edges, but my goal is to only fade them when the user has reached the beginning or end of the list. Essentially, I want the right edge to fade when the user is at the start and the left edge to fade when at the end. On larger screens with no scroll, there should be no fade effect. How can I accomplish this within MUI ImageList? While I can conditionally style the object, I'm struggling to determine the scroll position.
https://i.sstatic.net/L8BwM.jpg
import * as React from 'react';
import Image from 'next/image';
import ImageList from '@mui/material/ImageList';
import ImageListItem from '@mui/material/ImageListItem';
import ImageListItemBar from '@mui/material/ImageListItemBar';
import { styled } from "@mui/system"
import { NoEncryption } from '@mui/icons-material';
export default function TitlebarBelowImageList() {
return (
<AdBarContainer>
<ImageList sx={{
width: "100%",
gridAutoFlow: "column",
gridTemplateColumns: "repeat(auto-fill,minmax(15em, 1fr)) !important",
gridAutoColumns: "minmax(15em, 1fr)",
overflowX:'scroll',
maskImage: 'linear-gradient(to left, black calc(100% - 48px), transparent 100%)',
maskImage: 'linear-gradient(to right, transparent 0%, black 48px, black calc(100% - 48px), transparent 100%)',
}}
gap= {10}
variant= 'standard'
rowHeight= "auto"
>
{itemData.map((item) => (
<ImageListItem key={item.key}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
alt={item.title}
loading="lazy"
style={{borderRadius: 10}}
/>
<ImageListItemBar
title={item.title}
subtitle={<span>{item.subtitle}</span>}
position="below"
/>
</ImageListItem>
))}
</ImageList>
</AdBarContainer>
);
}
const itemData = [
{
key: 1,
img: '/img.jpg',
title: 'title',
subtitle: 'subtitle',
},
{
key: 2,
img: '/img.jpg',
title: 'title',
subtitle: 'subtitle',
},
{
key: 3,
img: '/img.jpg',
title: 'title',
subtitle: 'subtitle',
},
{
key: 4,
img: '/img.jpg',
title: 'title',
subtitle: 'subtitle',
},
{
key: 5,
img: '/img.jpg',
title: 'title',
subtitle: 'subtitle',
},
];