From bc27dc99a6b926a5c3bab216a6dbcce20e808967 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 16 Apr 2018 16:49:20 +0200 Subject: [PATCH] Fixed infinite scroll on AMV page --- mixins/AMV.pixy | 2 +- scripts/AnimeNotifier.ts | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mixins/AMV.pixy b/mixins/AMV.pixy index f245fe56..1882b3fa 100644 --- a/mixins/AMV.pixy +++ b/mixins/AMV.pixy @@ -2,7 +2,7 @@ component AMV(amv *arn.AMV, user *arn.User) .amv.mountable .video-container video.video.lazy(controls="controls", controlsList="nodownload") - div(data-src="/videos/amvs/" + amv.File, data-type="video/webm") + source(data-src="https://notify.moe/videos/amvs/" + amv.File, data-type="video/webm") AMVFooter(amv, user) diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index 35387fba..ba4ecca4 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -650,19 +650,23 @@ export default class AnimeNotifier { // Prevent context menu video.addEventListener("contextmenu", e => e.preventDefault()) - for(let child of video.children) { - let div = child as HTMLDivElement - let source = document.createElement("source") - source.src = div.dataset.src - source.type = div.dataset.type + let modified = false - Diff.mutations.queue(() => video.replaceChild(source, div)) + for(let child of video.children) { + let element = child as HTMLSourceElement + + if(element.src !== element.dataset.src) { + element.src = element.dataset.src + modified = true + } } - Diff.mutations.queue(() => { - video.load() - video.classList.add("element-found") - }) + if(modified) { + Diff.mutations.queue(() => { + video.load() + video.classList.add("element-found") + }) + } } this.visibilityObserver.observe(video)