Heavily improved page reload
This commit is contained in:
parent
80264f91b8
commit
cd6641cc06
@ -36,6 +36,9 @@ export class AnimeNotifier {
|
||||
Diff.persistentClasses.add("mounted")
|
||||
Diff.persistentClasses.add("image-found")
|
||||
|
||||
// Never remove src property on diffs
|
||||
Diff.persistentAttributes.add("src")
|
||||
|
||||
if("IntersectionObserver" in window) {
|
||||
// Enable lazy load
|
||||
this.visibilityObserver = new IntersectionObserver(
|
||||
@ -374,10 +377,10 @@ export class AnimeNotifier {
|
||||
|
||||
loading(isLoading: boolean) {
|
||||
if(isLoading) {
|
||||
document.body.style.cursor = "progress"
|
||||
document.documentElement.style.cursor = "progress"
|
||||
this.app.loading.classList.remove(this.app.fadeOutClass)
|
||||
} else {
|
||||
document.body.style.cursor = "auto"
|
||||
document.documentElement.style.cursor = "auto"
|
||||
this.app.loading.classList.add(this.app.fadeOutClass)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
export class Diff {
|
||||
static persistentClasses = new Set<string>()
|
||||
static persistentAttributes = new Set<string>()
|
||||
|
||||
// Reuse container for diffs to avoid memory allocation
|
||||
static container: HTMLElement
|
||||
@ -22,7 +23,9 @@ export class Diff {
|
||||
}
|
||||
|
||||
Diff.rootContainer.innerHTML = html.replace("<!DOCTYPE html>", "")
|
||||
Diff.childNodes(aRoot, Diff.rootContainer)
|
||||
console.log(aRoot.getElementsByTagName("body")[0])
|
||||
console.log(Diff.rootContainer.getElementsByTagName("body")[0])
|
||||
Diff.childNodes(aRoot.getElementsByTagName("body")[0], Diff.rootContainer.getElementsByTagName("body")[0])
|
||||
}
|
||||
|
||||
// childNodes diffs the child nodes of 2 given elements and applies DOM mutations.
|
||||
@ -80,7 +83,7 @@ export class Diff {
|
||||
let attrib = elemA.attributes[x]
|
||||
|
||||
if(attrib.specified) {
|
||||
if(!elemB.hasAttribute(attrib.name)) {
|
||||
if(!elemB.hasAttribute(attrib.name) && !Diff.persistentAttributes.has(attrib.name)) {
|
||||
removeAttributes.push(attrib)
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,7 @@ import { AnimeNotifier } from "./AnimeNotifier"
|
||||
let app = new Application()
|
||||
let arn = new AnimeNotifier(app)
|
||||
|
||||
arn.init()
|
||||
arn.init()
|
||||
|
||||
// For debugging purposes
|
||||
window["arn"] = arn
|
Loading…
Reference in New Issue
Block a user