joshwnj / react-visibility-sensor

Sensor component for React that notifies you when it goes in or out of the window viewport.
MIT License
2.32k stars 195 forks source link

How to check if element is only Partially Visible? #164

Open uijaswanthi opened 5 years ago

uijaswanthi commented 5 years ago

From the below example i understood that isVisible will return true even if div element visible partially because I added partialVisibility prop. But is there any way i can say if div element is partially visible or fully visible?

<VisibilitySensor key={list} partialVisibility containment={containmentDOMRect}>
  {({ isVisible }) => {
    return (
      <div
        style={{
          height: 100,
          lineHeight: "100px",
          color: "white",
          backgroundColor: isVisible ? "green" : "red",
          margin: 5
        }}
      >
      I am #{list}
      </div>);
    }}
</VisibilitySensor>