Fixed infinite scroll on AMV page

This commit is contained in:
Eduard Urbach 2018-04-16 16:49:20 +02:00
parent 8d50f9583e
commit bc27dc99a6
2 changed files with 15 additions and 11 deletions

View File

@ -2,7 +2,7 @@ component AMV(amv *arn.AMV, user *arn.User)
.amv.mountable .amv.mountable
.video-container .video-container
video.video.lazy(controls="controls", controlsList="nodownload") 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) AMVFooter(amv, user)

View File

@ -650,19 +650,23 @@ export default class AnimeNotifier {
// Prevent context menu // Prevent context menu
video.addEventListener("contextmenu", e => e.preventDefault()) video.addEventListener("contextmenu", e => e.preventDefault())
for(let child of video.children) { let modified = false
let div = child as HTMLDivElement
let source = document.createElement("source")
source.src = div.dataset.src
source.type = div.dataset.type
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(() => { if(modified) {
video.load() Diff.mutations.queue(() => {
video.classList.add("element-found") video.load()
}) video.classList.add("element-found")
})
}
} }
this.visibilityObserver.observe(video) this.visibilityObserver.observe(video)