logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

still-image.vue (1733B)


  1. <template>
  2. <div
  3. class="still-image"
  4. :class="{ animated: animated }"
  5. :style="style"
  6. >
  7. <canvas
  8. v-if="animated"
  9. ref="canvas"
  10. />
  11. <!-- NOTE: key is required to force to re-render img tag when src is changed -->
  12. <img
  13. ref="src"
  14. :key="realSrc"
  15. :alt="alt"
  16. :title="alt"
  17. :data-src="dataSrc"
  18. :src="realSrc"
  19. :referrerpolicy="referrerpolicy"
  20. :loading="loading"
  21. @load="onLoad"
  22. @error="onError"
  23. >
  24. <slot />
  25. </div>
  26. </template>
  27. <script src="./still-image.js"></script>
  28. <style lang="scss">
  29. .still-image {
  30. position: relative;
  31. line-height: 0;
  32. overflow: hidden;
  33. display: inline-flex;
  34. align-items: center;
  35. canvas {
  36. position: absolute;
  37. top: 0;
  38. bottom: 0;
  39. left: 0;
  40. right: 0;
  41. width: 100%;
  42. height: 100%;
  43. object-fit: contain;
  44. visibility: var(--_still-image-canvas-visibility, visible);
  45. }
  46. img {
  47. width: 100%;
  48. height: 100%;
  49. object-fit: contain;
  50. }
  51. &.animated {
  52. &::before {
  53. zoom: var(--_still_image-label-scale, 1);
  54. content: "gif";
  55. position: absolute;
  56. line-height: 1;
  57. font-size: 0.7em;
  58. top: 0.5em;
  59. left: 0.5em;
  60. background: rgb(127 127 127 / 50%);
  61. color: #fff;
  62. display: block;
  63. padding: 2px 4px;
  64. border-radius: var(--roundness);
  65. z-index: 2;
  66. visibility: var(--_still-image-label-visibility, visible);
  67. }
  68. &:hover canvas {
  69. display: none;
  70. }
  71. &:hover::before {
  72. visibility: var(--_still-image-label-visibility, hidden);
  73. }
  74. img {
  75. visibility: var(--_still-image-img-visibility, hidden);
  76. }
  77. &:hover img {
  78. visibility: visible;
  79. }
  80. }
  81. }
  82. </style>