Skip to content

Commit f99c3d5

Browse files
committed
HTMX infinite scroll trigger all set.
1 parent 7a5ea2a commit f99c3d5

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

code/ch7_infinite_scroll/ch7_final_video_collector/templates/feed/index.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
<h1>Video Collector: Recent Videos</h1>
77

8-
{{ render_partial('feed/partials/video_list.html', videos=videos) }}
8+
{{ render_partial('feed/partials/video_list.html',
9+
videos=videos,
10+
page=1,
11+
has_more_videos=has_more_videos) }}
912

1013
</div>
1114

code/ch7_infinite_scroll/ch7_final_video_collector/templates/feed/partials/video_list.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,13 @@
77
</a>
88
</div>
99

10-
{% endfor %}
10+
{% endfor %}
11+
12+
{% if has_more_videos %}
13+
<div class="scroll-trigger htmx-settling"
14+
hx-get="/feed/more_videos/{{ (page+1) }}"
15+
hx-trigger="revealed"
16+
hx-swap="outerHTML">
17+
<img src="/static/img/bars.svg" width="150px" class="htmx-indicator"/>
18+
</div>
19+
{% endif %}

code/ch7_infinite_scroll/ch7_final_video_collector/viewmodels/feed/feed_viewmodel.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ def __init__(self, page_size: int, page: int = 1):
1717
end = start + page_size
1818

1919
self.videos: List[Video] = all_videos[start:end]
20+
self.has_more_videos = len(all_videos) > end

0 commit comments

Comments
 (0)