karl-run / react-bottom-scroll-listener

A simple listener component that invokes a callback when the webpage is scrolled to the bottom.
https://karl-run.github.io/react-bottom-scroll-listener
149 stars 15 forks source link

Specific container behaviour #26

Closed ClementJanssens closed 3 years ago

ClementJanssens commented 4 years ago

I'm trying to set up a listener on specific container but callback func is called even if I scroll to bottom of body : behaviour of scrolling to bottom of body.

const containerRef = useBottomScrollListener(handleContainerOnBottom);

This line creates a body listener even I link JSX Element with reference

karl-run commented 4 years ago

Sorry for the horribly slow response.

If you don't pass the ref to an element, it will still behave as a document bottom scroll listener. If you still have this issue, can you show me how you are setting the ref?

If you are passing the ref to a React component, you will have to use React.forwardRef to forward the ref to an actual DOM-node.

karl-run commented 3 years ago

Hi,

I'm closing this. But feel free to re-open it if you need.