mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-26 01:37:28 +00:00
Improve pagination button appearance
This commit is contained in:
parent
788aaea3d1
commit
4cabab5026
@ -29,8 +29,25 @@ class NextPage extends FreezeWidth {
|
|||||||
|
|
||||||
onClick(event) {
|
onClick(event) {
|
||||||
if (event) event.preventDefault()
|
if (event) event.preventDefault()
|
||||||
if (this.clicked) return
|
if (this.fetching) return
|
||||||
this.clicked = true
|
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...")
|
this.freeze("Loading...")
|
||||||
|
|
||||||
fetch(`/fragment/user/${this.element.getAttribute("data-username")}/${this.nextPageNumber}`).then(res => res.text()).then(text => {
|
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()
|
addNextPageControl()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {IntersectionObserverEntry[]} entries
|
|
||||||
*/
|
|
||||||
onIntersect(entries) {
|
|
||||||
if (entries.some(entry => entry.isIntersecting && entry.intersectionRatio >= intersectionThreshold)) this.onClick()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNextPageControl() {
|
function addNextPageControl() {
|
||||||
|
Loading…
Reference in New Issue
Block a user