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
.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)

View File

@ -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)