Sample link to see the demonstration:
https://stackblitz.com/edit/react-5xt9r5?file=demo.tsx
I am looking for a way to conceal a fixed div once I reach the bottom of its parent container while scrolling down.
Below is a snippet illustrating how I structured the parent and fixed div elements:
<Box
sx={{
width: 400,
height: 300,
overflow: 'auto',
border: '1px solid #ccc',
borderRadius: '4px',
}}
>
<ul>
{Array.from({ length: 20 }, (_, index) => (
<li key={index}>{`Text ${index + 1}`}</li>
))}
</ul>
<Box
position="sticky"
bottom={0}
bgcolor="white"
p={2}
boxShadow={2}
zIndex={100}
>
Hide this Div when parent div scrolled down
</Box>
</Box>
I attempted to implement something using Material-UI's useScrollTrigger
but I struggled to find an example where I could specify the target parent (which is what I actually needed).