react-custom-scrollbars
react-custom-scrollbars copied to clipboard
how can i know that i scroll to the end?
According to the api's doc, i do not find any apis which can support me to listen the moment of scrolling to the end?
Yo ! I faced this issue, and this is how I resolved : :
const scrollbar = useRef(null);
const handleScrollAtBottom = () => {
const { scrollTop, scrollHeight, clientHeight } = scrollbar.current.getValues();
if (Math.round(scrollTop + clientHeight) >= scrollHeight)
console.log('i am at bottom');
}
<Scrollbars ref={scrollbar}>
</Scrollbars>
Yo ! I faced this issue, and this is how I resolved : :
const scrollbar = useRef(null); const handleScrollAtBottom = () => { const { scrollTop, scrollHeight, clientHeight } = scrollbar.current.getValues(); if (Math.round(scrollTop + clientHeight) >= scrollHeight) console.log('i am at bottom'); } <Scrollbars ref={scrollbar}> </Scrollbars>
3q! before get your mail, i had solved that problem by the same method
there is an onScrollFrame callback, which will give you a value.top = 1 at the end of the scroll. No need for acrobatics :)
there is an
onScrollFramecallback, which will give you avalue.top = 1at the end of the scroll. No need for acrobatics :)
nice!
const { scrollTop, scrollHeight, clientHeight } = scrollbar.current.getValues(); if (Math.round(scrollTop + clientHeight) >= scrollHeight) console.log('i am at bottom');
This is more reliable than the onScrollFrame