question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infinite scrolling

See original GitHub issue

I’m submitting a feature request

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here

Current behavior

Expected behavior

Reproduction of the problem

What is the motivation / use case for changing the behavior? When pulling data from an API, it’d be beneficial to auto-load the data once the scrollbar is at a certain percentage. The user wouldn’t have to click next for separate pages.

Please tell us about your environment:

  • Table version: 0.7.x
  • Angular version: 2.0.x
  • Browser: all

  • Language: all

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:8
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ychaikincommented, May 30, 2017

Offset is a 0 based number and represents the actual pagination I need to request to the server. The page is a 1 based number that reflects the actual ui position on the page. You can use these exclusive of each other to prefetch pages ahead of the actual page the user is on.

With the event.pageSize=7, the offset changes from 0 to 1 when I scroll down when the 8th row is fully shown. Almost like the description you gave for the ui position on the page instead of what I need to request from the server.

So, what do I look for to know to request the next 7 rows from the server? I can prefetch 14 rows (first 2 pages), but how will I know when the user is getting to close to the last few rows already pre-fetched.

I must admit that I dug into the code and did something slightly drastic to accomplish this. Feels like a leaky abstraction to me, but it works:

<ngx-datatable #table
        ...
        [scrollbarV]="true"
        (page)='onPage($event, table.bodyComponent.indexes)'>

Then, in component code:

currentlyLoadedPage = 0;
onPage(event: any, indexes: any) {
    // not precise, but close enough for now
    const totalShown = (this.currentlyLoadedPage + 1) * this.pageSize;
    const percentScrolled = indexes.last / (totalShown / 100);
    
    // pre-fetch the next page
    if (percentScrolled > 80) {
      this.currentlyLoadedPage++;
      this.addPage(this.currentlyLoadedPage);
    }
  }
0reactions
mulgurulcommented, Sep 16, 2020

Hi guys

I noticed that in the demo on a desktop browser, then scrolling using the arrows with a row marked, I get stuck on page 7 when trying to scrool back. Is this by design? So I reach end of data at page 8, and can scroll one page back to top of page seven. If this is a bug, then I can’t use this mode in my current project where I need real pageless/infinite scrolling.

Nb I’m using Chrome 84.0.4147.135 64bit on Windows, but I’ll do some more testing with mobile device, other browsers etc.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Infinite Scroll
Infinite Scroll is a JavaScript plugin that automatically adds the next page, saving users from a full page load. You've likely seen it...
Read more >
What Is Infinite Scrolling and How Does It Work? - MakeUseOf
Infinite scrolling is a technique that loads more content as you scroll. It allows you to continue scrolling indefinitely and is sometimes ...
Read more >
Infinite Scroll Advantages & Disadvantages | Built In
Infinite scroll is a web design technique where more content automatically and continuously loads at the bottom as users scroll down the page....
Read more >
The Infinite Scroll: Why It's So Addictive and How to Break Free
The infinite scrolling design pattern was created by engineer Aza Raskin in 2006. Later refined and further developed into a JavaScript plugin ...
Read more >
Infinite Scrolling - Examples - ScrollMagic
Dynamic content pages become scroll magical. An infinite-content page can be achieved by adding a scene that triggers at the bottom of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found