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:
parent
788aaea3d1
commit
4cabab5026
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user