logo

pleroma-fe

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

media_modal.vue (6372B)


  1. <template>
  2. <Modal
  3. v-if="showing"
  4. class="media-modal-view"
  5. @backdropClicked="hideIfNotSwiped"
  6. >
  7. <SwipeClick
  8. v-if="type === 'image'"
  9. ref="swipeClick"
  10. class="modal-image-container"
  11. :direction="swipeDirection"
  12. :threshold="swipeThreshold"
  13. :disable-click-threshold="swipeDisableClickThreshold"
  14. @preview-requested="handleSwipePreview"
  15. @swipe-finished="handleSwipeEnd"
  16. @swipeless-clicked="hide"
  17. >
  18. <PinchZoom
  19. ref="pinchZoom"
  20. class="modal-image-container-inner"
  21. selector=".modal-image"
  22. reach-min-scale-strategy="reset"
  23. stop-propagate-handled="stop-propgate-handled"
  24. :allow-pan-min-scale="pinchZoomMinScale"
  25. :min-scale="pinchZoomMinScale"
  26. :reset-to-min-scale-limit="pinchZoomScaleResetLimit"
  27. >
  28. <img
  29. :class="{ loading }"
  30. class="modal-image"
  31. :src="currentMedia.url"
  32. :alt="currentMedia.description"
  33. :title="currentMedia.description"
  34. @load="onImageLoaded"
  35. >
  36. </PinchZoom>
  37. </SwipeClick>
  38. <VideoAttachment
  39. v-if="type === 'video'"
  40. class="modal-image"
  41. :attachment="currentMedia"
  42. :controls="true"
  43. />
  44. <audio
  45. v-if="type === 'audio'"
  46. class="modal-image"
  47. :src="currentMedia.url"
  48. :alt="currentMedia.description"
  49. :title="currentMedia.description"
  50. controls
  51. />
  52. <Flash
  53. v-if="type === 'flash'"
  54. class="modal-image"
  55. :src="currentMedia.url"
  56. :alt="currentMedia.description"
  57. :title="currentMedia.description"
  58. />
  59. <button
  60. v-if="canNavigate"
  61. :title="$t('media_modal.previous')"
  62. class="modal-view-button modal-view-button-arrow modal-view-button-arrow--prev"
  63. @click.stop.prevent="goPrev"
  64. >
  65. <FAIcon
  66. class="button-icon arrow-icon"
  67. icon="chevron-left"
  68. />
  69. </button>
  70. <button
  71. v-if="canNavigate"
  72. :title="$t('media_modal.next')"
  73. class="modal-view-button modal-view-button-arrow modal-view-button-arrow--next"
  74. @click.stop.prevent="goNext"
  75. >
  76. <FAIcon
  77. class="button-icon arrow-icon"
  78. icon="chevron-right"
  79. />
  80. </button>
  81. <button
  82. class="modal-view-button modal-view-button-hide"
  83. :title="$t('media_modal.hide')"
  84. @click.stop.prevent="hide"
  85. >
  86. <FAIcon
  87. class="button-icon"
  88. icon="times"
  89. />
  90. </button>
  91. <span
  92. v-if="description"
  93. class="description"
  94. >
  95. {{ description }}
  96. </span>
  97. <span
  98. class="counter"
  99. >
  100. {{ $tc('media_modal.counter', currentIndex + 1, { current: currentIndex + 1, total: media.length }) }}
  101. </span>
  102. <span
  103. v-if="loading"
  104. class="loading-spinner"
  105. >
  106. <FAIcon
  107. spin
  108. icon="circle-notch"
  109. size="5x"
  110. />
  111. </span>
  112. </Modal>
  113. </template>
  114. <script src="./media_modal.js"></script>
  115. <style lang="scss">
  116. $modal-view-button-icon-height: 3em;
  117. $modal-view-button-icon-half-height: calc(#{$modal-view-button-icon-height} / 2);
  118. $modal-view-button-icon-width: 3em;
  119. $modal-view-button-icon-margin: 0.5em;
  120. .media-modal-view {
  121. @keyframes media-fadein {
  122. from {
  123. opacity: 0;
  124. }
  125. to {
  126. opacity: 1;
  127. }
  128. }
  129. .modal-image-container {
  130. display: flex;
  131. overflow: hidden;
  132. align-items: center;
  133. flex-direction: column;
  134. max-width: 100%;
  135. max-height: 100%;
  136. width: 100%;
  137. height: 100%;
  138. flex-grow: 1;
  139. justify-content: center;
  140. &-inner {
  141. width: 100%;
  142. height: 100%;
  143. flex-grow: 1;
  144. display: flex;
  145. flex-direction: column;
  146. align-items: center;
  147. justify-content: center;
  148. }
  149. }
  150. .description,
  151. .counter {
  152. /* Hardcoded since background is also hardcoded */
  153. color: white;
  154. margin-top: 1em;
  155. text-shadow: 0 0 10px black, 0 0 10px black;
  156. padding: 0.2em 2em;
  157. }
  158. .description {
  159. flex: 0 0 auto;
  160. overflow-y: auto;
  161. min-height: 1em;
  162. max-width: 500px;
  163. max-height: 9.5em;
  164. word-break: break-all;
  165. }
  166. .modal-image {
  167. max-width: 100%;
  168. max-height: 100%;
  169. image-orientation: from-image; // NOTE: only FF supports this
  170. animation: 0.1s cubic-bezier(0.7, 0, 1, 0.6) media-fadein;
  171. &.loading {
  172. opacity: 0.5;
  173. }
  174. }
  175. .loading-spinner {
  176. width: 100%;
  177. height: 100%;
  178. position: absolute;
  179. pointer-events: none;
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. svg {
  184. color: white;
  185. }
  186. }
  187. .modal-view-button {
  188. border: 0;
  189. padding: 0;
  190. opacity: 0;
  191. box-shadow: none;
  192. background: none;
  193. appearance: none;
  194. overflow: visible;
  195. cursor: pointer;
  196. transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1);
  197. height: $modal-view-button-icon-height;
  198. width: $modal-view-button-icon-width;
  199. .button-icon {
  200. position: absolute;
  201. height: $modal-view-button-icon-height;
  202. width: $modal-view-button-icon-width;
  203. font-size: 1rem;
  204. line-height: $modal-view-button-icon-height;
  205. color: #fff;
  206. text-align: center;
  207. background-color: rgb(0 0 0 / 30%);
  208. }
  209. }
  210. .modal-view-button-arrow {
  211. position: absolute;
  212. display: block;
  213. top: 50%;
  214. margin-top: $modal-view-button-icon-half-height;
  215. width: $modal-view-button-icon-width;
  216. height: $modal-view-button-icon-height;
  217. .arrow-icon {
  218. position: absolute;
  219. top: 0;
  220. line-height: $modal-view-button-icon-height;
  221. color: #fff;
  222. text-align: center;
  223. background-color: rgb(0 0 0 / 30%);
  224. }
  225. &--prev {
  226. left: 0;
  227. .arrow-icon {
  228. left: $modal-view-button-icon-margin;
  229. }
  230. }
  231. &--next {
  232. right: 0;
  233. .arrow-icon {
  234. right: $modal-view-button-icon-margin;
  235. }
  236. }
  237. }
  238. .modal-view-button-hide {
  239. position: absolute;
  240. top: 0;
  241. right: 0;
  242. .button-icon {
  243. top: $modal-view-button-icon-margin;
  244. right: $modal-view-button-icon-margin;
  245. }
  246. }
  247. }
  248. .modal-view.media-modal-view {
  249. z-index: var(--ZI_media_modal);
  250. flex-direction: column;
  251. .modal-view-button-arrow,
  252. .modal-view-button-hide {
  253. opacity: 0.75;
  254. &:focus,
  255. &:hover {
  256. outline: none;
  257. box-shadow: none;
  258. }
  259. &:hover {
  260. opacity: 1;
  261. }
  262. }
  263. overflow: hidden;
  264. }
  265. </style>