demo link:
https://stackblitz.com/edit/react-5xt9r5?file=demo.tsx
I want to hide a sticky div when I reached the buttom of a parent div while scrolling down.
this is a code example of how I set a parent div and the sticky div
<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 tried to do something with Material useScrollTrigger
but I could not find a example where I can decide the parent target (what was actually working)
2
Answers
was a solution..
Hi my friend there is another solution for this using the useScrollTrigger
Hope it helps