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