loktar00 / react-lazy-load

React component that renders children elements when they enter the viewport.
MIT License
978 stars 166 forks source link

Allow passing a root prop to IntersectionObserver #169

Open santialbo opened 1 year ago

santialbo commented 1 year ago

If using this on elements inside a scrollable div, you need to pass the root prop in order for the offset to work correctly. Otherwise offset is "ignored" and elements are only "visible" when they are actually visibile.

We just need a new root prop of type Element that can be passed optionally to the IntersectionObserver constructor