How to get if scrollbar reach to bottom of Div
mrjosshi opened this issue · comments
Anil Joshi commented
react-smooth-scrollbars scrollTop always returns 0
Ray Agor commented
There is a props that you could pass a callback function called onScroll
, this will return 2 params. the first one will be the limit and the offset and the second one will be the whole Scrollbar stuff.
the first parameter will return something like
{
limit: {
x: 0,
y: 100
},
offset: {
x: 0,
y: 0
},
}
Where limit is your max and offset is your current "scrollTop". With that you could determine if the scroll reached the bottom or not with the example below.
handleScroll(scroll) {
const haveReachedBottom = scroll.offset.y === scroll.limit.y;
if (haveReachedBottom) { // do something }
}
// your render
<ScrollBar onScroll={handleScroll}></ScrollBar>
Anil Joshi commented
@kamoteshake thank you very much that is exactly what i was looking for. Again thanks a lot for quick response