Improved editor logs

This commit is contained in:
2018-04-09 13:44:02 +02:00
parent 66bd51f603
commit 719c04f3d5
5 changed files with 120 additions and 54 deletions

View File

@ -1,3 +1,5 @@
import Diff from "./Diff"
export default class InfiniteScroller {
container: HTMLElement
threshold: number
@ -6,10 +8,21 @@ export default class InfiniteScroller {
this.container = container
this.threshold = threshold
this.container.addEventListener("scroll", e => {
let check = () => {
if(this.container.scrollTop + this.container.clientHeight >= this.container.scrollHeight - threshold) {
this.loadMore()
}
}
this.container.addEventListener("scroll", e => {
// Wait for mutations to finish before checking if we need infinite scroll to trigger.
if(Diff.mutations.mutations.length > 0) {
Diff.mutations.wait(() => check())
return
}
// Otherwise, check immediately.
check()
})
}