visibility sensor for an element in a page
imbhargav5 opened this issue · 4 comments
imbhargav5 commented
Check if an element is scrolled into view.
import {useRef} from "react"
import useVisibilitySensor from '@rehooks/visibility-sensor';
const StyledDiv = styled.div`
opacity : ${props=>props.isVisible? 1 : 0.2};
`
function MyComponent() {
const elementToObserve = useRef(null);
let visibility = useVisibilitySensor(elementToObserve);
return <StyledDiv ref={elementToObserve} {...visibility} />;
}
I want to claim this if it's possible.
imbhargav5 commented
Started work on it.
imbhargav5 commented
Almost done.
imbhargav5 commented
@jamiebuilds What do you think?