1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-22 08:07:30 +00:00

Improve pagination button appearance

This commit is contained in:
Cadence Fish 2020-01-28 23:37:45 +13:00
parent 788aaea3d1
commit 4cabab5026
No known key found for this signature in database
GPG Key ID: 81015DF9AA8607E1

View File

@ -29,8 +29,25 @@ class NextPage extends FreezeWidth {
onClick(event) {
if (event) event.preventDefault()
if (this.clicked) return
this.clicked = true
if (this.fetching) return
this.class("clicked")
this.fetch()
}
/**
* @param {IntersectionObserverEntry[]} entries
*/
onIntersect(entries) {
if (entries.some(entry => entry.isIntersecting && entry.intersectionRatio >= intersectionThreshold)) {
if (this.fetching) return
this.class("disabled")
this.fetch()
}
}
fetch() {
if (this.fetching) return
this.fetching = true
this.freeze("Loading...")
fetch(`/fragment/user/${this.element.getAttribute("data-username")}/${this.nextPageNumber}`).then(res => res.text()).then(text => {
@ -40,13 +57,6 @@ class NextPage extends FreezeWidth {
addNextPageControl()
})
}
/**
* @param {IntersectionObserverEntry[]} entries
*/
onIntersect(entries) {
if (entries.some(entry => entry.isIntersecting && entry.intersectionRatio >= intersectionThreshold)) this.onClick()
}
}
function addNextPageControl() {