fix: replace revealed sentinel with intersect once for infinite scroll
This commit is contained in:
@@ -20,19 +20,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div id="anime-grid" class="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6">
|
<div id="anime-grid" class="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6">
|
||||||
{{range $i, $anime := .Animes}}
|
{{range .Animes}}
|
||||||
{{$isThreshold := eq (add $i 1) (sub (len $.Animes) 8)}}
|
|
||||||
{{if and $isThreshold $.HasNextPage}}
|
|
||||||
<div hx-get="/browse?q={{$.Query}}&type={{$.Type}}&status={{$.Status}}&order_by={{$.OrderBy}}&sort={{$.Sort}}&sfw={{$.SFW}}&{{genresParams $.Genres}}&page={{$.NextPage}}"
|
|
||||||
hx-trigger="revealed"
|
|
||||||
hx-swap="afterend"
|
|
||||||
hx-target="this"
|
|
||||||
class="contents">
|
|
||||||
{{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}}
|
|
||||||
</div>
|
|
||||||
{{else}}
|
|
||||||
{{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}}
|
{{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{if .HasNextPage}}
|
||||||
|
{{template "browse_sentinel" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
@@ -41,19 +33,18 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{define "anime_card_scroll"}}
|
{{define "anime_card_scroll"}}
|
||||||
{{$count := len .Animes}}
|
{{range .Animes}}
|
||||||
{{range $i, $anime := .Animes}}
|
{{template "anime_card" dict "Anime" . "WithActions" true "IsWatchlist" (index $.WatchlistMap .MalID)}}
|
||||||
{{$isThreshold := eq (add $i 1) (sub $count 8)}}
|
{{end}}
|
||||||
{{if and $isThreshold $.HasNextPage}}
|
{{if .HasNextPage}}
|
||||||
<div hx-get="/browse?q={{$.Query}}&type={{$.Type}}&status={{$.Status}}&order_by={{$.OrderBy}}&sort={{$.Sort}}&sfw={{$.SFW}}&{{genresParams $.Genres}}&page={{$.NextPage}}"
|
{{template "browse_sentinel" .}}
|
||||||
hx-trigger="revealed"
|
{{end}}
|
||||||
hx-swap="afterend"
|
{{end}}
|
||||||
|
|
||||||
|
{{define "browse_sentinel"}}
|
||||||
|
<div hx-get="/browse?q={{.Query}}&type={{.Type}}&status={{.Status}}&order_by={{.OrderBy}}&sort={{.Sort}}&sfw={{.SFW}}&{{genresParams .Genres}}&page={{.NextPage}}"
|
||||||
|
hx-trigger="intersect once"
|
||||||
|
hx-swap="outerHTML"
|
||||||
hx-target="this"
|
hx-target="this"
|
||||||
class="contents">
|
class="col-span-full h-px"></div>
|
||||||
{{template "anime_card" dict "Anime" $anime "WithActions" true "IsWatchlist" (index $.WatchlistMap $anime.MalID)}}
|
|
||||||
</div>
|
|
||||||
{{else}}
|
|
||||||
{{template "anime_card" dict "Anime" $anime "WithActions" true "IsWatchlist" (index $.WatchlistMap $anime.MalID)}}
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
Reference in New Issue
Block a user