[images] no scrolling in lightbox

This commit is contained in:
Avris 2021-01-07 23:27:28 +01:00
parent 77e5a828e1
commit 0d1710d514
1 changed files with 3 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div :class="['lightbox-wrapper', currentUrl === null ? 'd-none' : '']" ref="wrapper" @click.self="hide"> <div :class="['lightbox-wrapper', currentUrl === null ? 'd-none' : '']" ref="wrapper" @click.self="hide">
<div :class="['lightbox-inner', center ? 'align-items-center' : '']" ref="inner" @click.self="hide"> <div :class="['lightbox-inner', 'align-items-center']" ref="inner" @click.self="hide">
<img class="lightbox-image" :src="currentUrl" ref="image" @load="loaded"> <img class="lightbox-image" :src="currentUrl" ref="image">
</div> </div>
<span class="lightbox-menu"> <span class="lightbox-menu">
<span class="lightbox-close fal fa-times" @click="hide"></span> <span class="lightbox-close fal fa-times" @click="hide"></span>
@ -14,7 +14,6 @@
data() { data() {
return { return {
currentUrl: null, currentUrl: null,
center: false,
}; };
}, },
mounted() { mounted() {
@ -24,13 +23,6 @@
return; return;
} }
document.addEventListener('resize', e => {
if (!this.currentUrl) {
return;
}
this.center = this.$refs.image.offsetHeight < this.$refs.inner.offsetHeight;
});
document.body.addEventListener('keyup', e => { document.body.addEventListener('keyup', e => {
if (!this.currentUrl) { if (!this.currentUrl) {
return; return;
@ -52,12 +44,6 @@
hide() { hide() {
this.currentUrl = null; this.currentUrl = null;
this.$refs.inner.blur(); this.$refs.inner.blur();
this.center = false;
},
loaded() {
if (this.$refs.image.offsetHeight < this.$refs.inner.offsetHeight) {
this.center = true;
}
}, },
}, },
}; };
@ -90,6 +76,7 @@
img { img {
max-width: 100%; max-width: 100%;
max-height: 100%;
} }
} }