pleroma-fe/src/components/still-image/still-image.vue

91 lines
1.7 KiB
Vue
Raw Normal View History

2018-01-29 18:47:26 +11:00
<template>
2019-07-05 17:17:44 +10:00
<div
class="still-image"
:class="{ animated: animated }"
>
<canvas
v-if="animated"
ref="canvas"
/>
2019-09-05 01:23:47 +10:00
<!-- NOTE: key is required to force to re-render img tag when src is changed -->
2019-07-05 17:17:44 +10:00
<img
ref="src"
2020-06-28 16:31:57 +10:00
:key="src"
2019-02-18 16:03:26 +11:00
:alt="alt"
:title="alt"
2019-07-05 17:17:44 +10:00
:src="src"
:referrerpolicy="referrerpolicy"
@load="onLoad"
@error="onError"
>
2018-01-29 18:47:26 +11:00
</div>
</template>
<script src="./still-image.js"></script>
<style lang="scss">
@import '../../_variables.scss';
2018-01-29 18:47:26 +11:00
.still-image {
position: relative;
line-height: 0;
overflow: hidden;
display: inline-flex;
align-items: center;
canvas {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
object-fit: contain;
2020-10-30 06:39:36 +11:00
visibility: var(--_still-image-canvas-visibility, visible);
}
img {
width: 100%;
min-height: 100%;
2018-09-04 05:49:46 +10:00
object-fit: contain;
}
&.animated {
&::before {
zoom: var(--_still_image-label-scale, 1);
content: 'gif';
position: absolute;
line-height: 10px;
font-size: 10px;
top: 5px;
left: 5px;
background: rgba(127, 127, 127, 0.5);
color: #fff;
display: block;
padding: 2px 4px;
2018-04-08 21:45:12 +10:00
border-radius: $fallback--tooltipRadius;
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
z-index: 2;
2020-10-30 06:39:36 +11:00
visibility: var(--_still-image-label-visibility, visible);
2018-01-29 18:47:26 +11:00
}
&:hover canvas {
display: none;
}
2020-10-30 06:39:36 +11:00
&:hover::before {
visibility: var(--_still-image-label-visibility, hidden);
}
img {
2020-10-30 06:39:36 +11:00
visibility: var(--_still-image-img-visibility, hidden);
}
&:hover img {
visibility: visible;
}
}
2018-01-29 18:47:26 +11:00
}
</style>