idiotWu / react-smooth-scrollbar

[Not Actively Maintained] A wrapper for smooth-scrollbar to React Component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get if scrollbar reach to bottom of Div

mrjosshi opened this issue · comments

react-smooth-scrollbars scrollTop always returns 0

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>

@kamoteshake thank you very much that is exactly what i was looking for. Again thanks a lot for quick response