yandere_fe/src/components/media_modal/media_modal.vue

208 lines
4.0 KiB
Vue
Raw Normal View History

<template>
<Modal
2019-07-05 00:17:44 -07:00
v-if="showing"
class="media-modal-view"
2019-10-21 17:52:31 -07:00
@backdropClicked="hide"
2019-07-05 00:17:44 -07:00
>
<img
v-if="type === 'image'"
2021-08-15 15:02:56 -07:00
:class="{ loading }"
class="modal-image"
2019-07-05 00:17:44 -07:00
:src="currentMedia.url"
2019-02-17 21:03:26 -08:00
:alt="currentMedia.description"
:title="currentMedia.description"
@touchstart.stop="mediaTouchStart"
@touchmove.stop="mediaTouchMove"
@touchend.stop="mediaTouchEnd"
2019-11-14 11:07:05 -08:00
@click="hide"
2021-08-15 15:02:56 -07:00
@load="onImageLoaded"
2019-07-06 14:54:17 -07:00
>
2019-07-05 00:17:44 -07:00
<VideoAttachment
v-if="type === 'video'"
2019-07-05 00:17:44 -07:00
class="modal-image"
2019-01-26 07:45:03 -08:00
:attachment="currentMedia"
:controls="true"
2019-07-05 00:17:44 -07:00
/>
<audio
v-if="type === 'audio'"
class="modal-image"
:src="currentMedia.url"
:alt="currentMedia.description"
:title="currentMedia.description"
controls
/>
<Flash
v-if="type === 'flash'"
class="modal-image"
:src="currentMedia.url"
:alt="currentMedia.description"
:title="currentMedia.description"
/>
2019-02-19 08:33:40 -08:00
<button
2019-07-05 00:17:44 -07:00
v-if="canNavigate"
2019-02-19 08:33:40 -08:00
:title="$t('media_modal.previous')"
class="modal-view-button-arrow modal-view-button-arrow--prev"
@click.stop.prevent="goPrev"
>
2020-10-20 14:31:16 -07:00
<FAIcon
class="arrow-icon"
icon="chevron-left"
/>
2019-02-19 08:33:40 -08:00
</button>
<button
2019-07-05 00:17:44 -07:00
v-if="canNavigate"
2019-02-19 08:33:40 -08:00
:title="$t('media_modal.next')"
class="modal-view-button-arrow modal-view-button-arrow--next"
@click.stop.prevent="goNext"
>
2020-10-20 14:31:16 -07:00
<FAIcon
class="arrow-icon"
icon="chevron-right"
/>
2019-02-19 08:33:40 -08:00
</button>
2021-08-15 09:45:48 -07:00
<span
v-if="description"
class="description"
>
{{ description }}
</span>
2021-08-15 15:11:16 -07:00
<span
class="counter"
>
{{ $tc('media_modal.counter', currentIndex + 1, { current: currentIndex + 1, total: media.length }) }}
2021-08-15 15:11:16 -07:00
</span>
2021-08-15 15:02:56 -07:00
<span
v-if="loading"
class="loading-spinner"
>
<FAIcon
spin
icon="circle-notch"
size="5x"
/>
</span>
</Modal>
</template>
<script src="./media_modal.js"></script>
<style lang="scss">
2019-10-18 09:13:11 -07:00
.modal-view.media-modal-view {
z-index: 1001;
2021-08-15 09:45:48 -07:00
flex-direction: column;
.modal-view-button-arrow {
opacity: 0.75;
2019-02-10 10:26:08 -08:00
&:focus,
&:hover {
outline: none;
box-shadow: none;
}
2021-08-15 15:02:56 -07:00
&:hover {
opacity: 1;
}
2019-02-19 08:33:40 -08:00
}
}
2021-08-15 09:45:48 -07:00
.media-modal-view {
@keyframes media-fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
2021-08-15 15:11:16 -07:00
.description,
.counter {
/* Hardcoded since background is also hardcoded */
2021-08-15 09:45:48 -07:00
color: white;
margin-top: 1em;
text-shadow: 0 0 10px black, 0 0 10px black;
2021-08-15 15:11:16 -07:00
padding: 0.2em 2em;
}
.description {
flex: 0 0 auto;
overflow-y: auto;
min-height: 1em;
2021-08-15 09:45:48 -07:00
max-width: 500px;
max-height: 9.5em;
2021-08-15 15:11:16 -07:00
word-break: break-all;
2021-08-15 09:45:48 -07:00
}
2021-08-15 09:45:48 -07:00
.modal-image {
max-width: 90%;
max-height: 90%;
box-shadow: 0px 5px 15px 0 rgba(0, 0, 0, 0.5);
image-orientation: from-image; // NOTE: only FF supports this
animation: 0.1s cubic-bezier(0.7, 0, 1, 0.6) media-fadein;
2021-08-15 15:02:56 -07:00
&.loading {
opacity: 0.5;
}
}
.loading-spinner {
width: 100%;
height: 100%;
position: absolute;
pointer-events: none;
display: flex;
justify-content: center;
align-items: center;
2021-08-15 15:11:16 -07:00
2021-08-15 15:02:56 -07:00
svg {
color: white;
}
2021-08-15 09:45:48 -07:00
}
2019-02-19 08:33:40 -08:00
2021-08-15 09:45:48 -07:00
.modal-view-button-arrow {
2019-02-19 08:33:40 -08:00
position: absolute;
2021-08-15 09:45:48 -07:00
display: block;
top: 50%;
margin-top: -50px;
width: 70px;
height: 100px;
border: 0;
padding: 0;
opacity: 0;
box-shadow: none;
background: none;
appearance: none;
overflow: visible;
cursor: pointer;
transition: opacity 333ms cubic-bezier(.4,0,.22,1);
2019-02-19 08:33:40 -08:00
.arrow-icon {
2021-08-15 09:45:48 -07:00
position: absolute;
top: 35px;
height: 30px;
width: 32px;
font-size: 14px;
line-height: 30px;
color: #FFF;
text-align: center;
background-color: rgba(0,0,0,.3);
}
2021-08-15 09:45:48 -07:00
&--prev {
left: 0;
.arrow-icon {
left: 6px;
}
}
&--next {
right: 0;
.arrow-icon {
right: 6px;
}
}
}
}
</style>