viewer: add missing null check for flags
parent
ef083c8575
commit
da863078e9
|
@ -254,7 +254,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
// Video support
|
// Video support
|
||||||
this.photoswipe.on("contentLoad", (e) => {
|
this.photoswipe.on("contentLoad", (e) => {
|
||||||
const { content, isLazy } = e;
|
const { content, isLazy } = e;
|
||||||
if (content.data.photo.flag & this.c.FLAG_IS_VIDEO) {
|
if ((content.data?.photo?.flag || 0) & this.c.FLAG_IS_VIDEO) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
content.type = "video";
|
content.type = "video";
|
||||||
|
@ -295,7 +295,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
// Play video on open slide
|
// Play video on open slide
|
||||||
this.photoswipe.on("slideActivate", (e) => {
|
this.photoswipe.on("slideActivate", (e) => {
|
||||||
const { slide } = e;
|
const { slide } = e;
|
||||||
if (slide.data.photo.flag & this.c.FLAG_IS_VIDEO) {
|
if ((slide.data?.photo?.flag || 0) & this.c.FLAG_IS_VIDEO) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
slide.content.element.querySelector("video")?.play();
|
slide.content.element.querySelector("video")?.play();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
@ -305,7 +305,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
// Pause video on close slide
|
// Pause video on close slide
|
||||||
this.photoswipe.on("slideDeactivate", (e) => {
|
this.photoswipe.on("slideDeactivate", (e) => {
|
||||||
const { slide } = e;
|
const { slide } = e;
|
||||||
if (slide.data.photo.flag & this.c.FLAG_IS_VIDEO) {
|
if ((slide.data?.photo?.flag || 0) & this.c.FLAG_IS_VIDEO) {
|
||||||
slide.content.element.querySelector("video")?.pause();
|
slide.content.element.querySelector("video")?.pause();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -428,7 +428,7 @@ export default class Viewer extends Mixins(GlobalMixin) {
|
||||||
|
|
||||||
// Scroll to keep the thumbnail in view
|
// Scroll to keep the thumbnail in view
|
||||||
this.photoswipe.on("slideActivate", (e) => {
|
this.photoswipe.on("slideActivate", (e) => {
|
||||||
const thumb = this.thumbElem(e.slide.data.photo);
|
const thumb = this.thumbElem(e.slide.data?.photo);
|
||||||
if (thumb) {
|
if (thumb) {
|
||||||
const rect = thumb.getBoundingClientRect();
|
const rect = thumb.getBoundingClientRect();
|
||||||
if (rect.top < 0 || rect.bottom > window.innerHeight) {
|
if (rect.top < 0 || rect.bottom > window.innerHeight) {
|
||||||
|
|
Loading…
Reference in New Issue