idiotWu / smooth-scrollbar

Customizable, Extendable, and High-Performance JavaScript-Based Scrollbar Solution.

Home Page:https://idiotwu.github.io/smooth-scrollbar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to check if Scroll has reached the bottom.

kurnyaannn opened this issue · comments

commented

Environment

  • Browser: Firefox 89
  • Version of smooth-scrollbar: 8.6.3

Issue Summary

First of all thanks for this amazing package you made, it's awesome. Well anyway i just wanted to know if Smooth Scrollbar has a way to find out if the scroll has reached the bottom ?

i'm going to make my data list having Infinite Scroll method, but i still struglling how to check if the scroll has reached the bottom i order to fetch new data. Any clue might be really helpfull, thanks.

You can compare scrollbar.offset.y with scrollbar.limit.y, check the infinite scrolling implement in smooth-scrollbar@7.x.

commented

Whoa, such a fast response. Thanks for the advice, and this is how i came up with :

      ....
      scrollbar.addListener((status) => {
        const offset = status.offset
        if (offset.y === scrollbar.limit.y) {
          fetchMoreData()
        }
      })
      ...

I don't know if that was the correct solution for this issue, but it works. Thanks.