I could use some feedback (especially from the javascript guru’s who can point out improvements!) on an infinite scroll component I’ve been working on that (hopefully) makes the process of building an infinite scroll easier than manually building.
The infinite scroll component attaches to a server connect, and triggers data loading based on the scrolling of the page, or a scrollable container. Displaying the content is done in the same manner as before (ie. setup a repeating row and use a server connect recordset for its expression.)
Screen Recording 2023-03-15 at 12.48.53 PM
npm at wappler_infinite_scroll
Step by step
Step by step:
Here is how you install (standard Wappler instructions):
You should see in the output:
Create a vanilla server API that has a paged query:
To your front end page, add a vanilla server connect using that API:
Add the Infinite Scroll component:
Set the Scrolling dataset on the properties by selecting the recordset from your paged query:
Create a repeat children row as you normally would, using your server connect for the expression (do not use the infinite scroll component here, use the server connect.)
Controls
-
Scrolling dataset must be a server connect paged query
-
Scrolling container is optional. The default is to use the entire page as the scrollable area. You may provide an element id of a scrollable container. For example, this container
<div class="container" id="scrolling_container" style="height: 300px; overflow: scroll;">
will have a scrollable area within the page. -
Debounce inserts a delay in how often the data is refreshed
-
Pixels before end allows you to set the scroll point at which time a refresh is triggered. A greater number indicates it should refresh earlier in the scroll.
-
The Infinite Scroll component has a data value of “executing” which can be used to display whatever busy indicator you wish to use.