I would like to be able to "bind" the useScrollTrigger
hook to a specific Component
/Node
rather than the window
default value.
The following shows the useScrollTrigger
expected parameters:
export interface UseScrollTriggerOptions {
disableHysteresis?: boolean;
target?: Node | Window;
threshold?: number;
}
I tried to pass a reference to my Component but this has caused a crash. The Material-UI library does not explain how to use useScrollTrigger
for things other than interactions with an AppBar
.
The following code snippets illustrates what I would like to achieve:
const ref = React.useRef();
const scrollTrigger = useScrollTrigger({
disableHysteresis: true,
target: ref.current,
});
<Grid container spacing={2}>
{services.map((service) => (
<Grid key={uid(service)} item md={4} sm={6} xs={12}>
<Grow
mountOnEnter
in={scrollTrigger}
timeout={2048}
>
<Card
ref={ref}
className={classes.card}
elevation={2}
>
<CardHeader --- REDACTED ---/>
<CardContent --- REDACTED --->
--- REDACTED ---
</CardContent>
<CardActions --- REDACTED --->
--- REDACTED ---
</Card>
</Grow>
</Grid>
))}
</Grid>