Infinite Scroll
The infinite scroll pattern provides a way to load content dynamically on user scrolling action.
Let’s focus on the final row (or the last element of your content):
<tr hx-get="/contacts/?page=2"
hx-trigger="revealed"
hx-swap="afterend">
<td>Agent Smith</td>
<td>void29@null.org</td>
<td>55F49448C0</td>
</tr>
This last element contains a listener which, when scrolled into view, will trigger a request. The result is then appended after it. The last element of the results will itself contain the listener to load the next page of results, and so on.
revealed- triggered when an element is scrolled into the viewport (also useful for lazy-loading). If you are usingoverflowin css likeoverflow-y: scrollyou should useintersect onceinstead ofrevealed.
Server Requests ↑ Show
HTML
🔗Demo
| Name | ID | |
|---|---|---|
| Agent Smith | void10@null.org | |
| Agent Smith | void11@null.org | |
| Agent Smith | void12@null.org | |
| Agent Smith | void13@null.org | |
| Agent Smith | void14@null.org | |
| Agent Smith | void15@null.org | |
| Agent Smith | void16@null.org | |
| Agent Smith | void17@null.org | |
| Agent Smith | void18@null.org | |
| Agent Smith | void19@null.org | |
| Agent Smith | void20@null.org | |
| Agent Smith | void21@null.org | |
| Agent Smith | void22@null.org | |
| Agent Smith | void23@null.org | |
| Agent Smith | void24@null.org | |
| Agent Smith | void25@null.org | |
| Agent Smith | void26@null.org | |
| Agent Smith | void27@null.org | |
| Agent Smith | void28@null.org | |
| Agent Smith | void29@null.org |