psvideo: fix preview of video

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/504/head
Varun Patil 2023-03-18 21:35:31 -07:00
parent d2122c1e3a
commit efec80523a
1 changed files with 6 additions and 18 deletions

View File

@ -42,7 +42,6 @@ class VideoContentSetup {
lightbox.on("contentDestroy", this.onContentDestroy.bind(this)); lightbox.on("contentDestroy", this.onContentDestroy.bind(this));
lightbox.on("contentActivate", this.onContentActivate.bind(this)); lightbox.on("contentActivate", this.onContentActivate.bind(this));
lightbox.on("contentDeactivate", this.onContentDeactivate.bind(this)); lightbox.on("contentDeactivate", this.onContentDeactivate.bind(this));
lightbox.on("contentAppend", this.onContentAppend.bind(this));
lightbox.on("contentResize", this.onContentResize.bind(this)); lightbox.on("contentResize", this.onContentResize.bind(this));
lightbox.addFilter( lightbox.addFilter(
@ -95,10 +94,7 @@ class VideoContentSetup {
pswp.on("appendHeavy", (e) => { pswp.on("appendHeavy", (e) => {
if (isVideoContent(e.slide)) { if (isVideoContent(e.slide)) {
const content = <any>e.slide.content; const content = <any>e.slide.content;
if (e.slide.isActive && content.videoElement) {
if (!e.slide.isActive) {
e.preventDefault();
} else if (content.videoElement) {
this.initVideo(content); this.initVideo(content);
} }
} }
@ -497,20 +493,9 @@ class VideoContentSetup {
this.destroyVideo(content); this.destroyVideo(content);
} }
onContentAppend(e) {
if (isVideoContent(e.content)) {
e.preventDefault();
e.content.isAttached = true;
e.content.appendImage();
}
}
onContentLoad(e) { onContentLoad(e) {
const content = e.content; // todo: videocontent const content = e.content;
if (!isVideoContent(e.content)) return;
if (!isVideoContent(e.content)) {
return;
}
// stop default content load // stop default content load
e.preventDefault(); e.preventDefault();
@ -519,6 +504,9 @@ class VideoContentSetup {
// Create DIV // Create DIV
content.element = document.createElement("div"); content.element = document.createElement("div");
content.element.classList.add("pswp__img");
content.element.style.background = `url(${content.data.msrc})`;
content.element.style.backgroundSize = "cover";
if (config_videoIsSetup) { if (config_videoIsSetup) {
content.state = "loading"; content.state = "loading";