PaintingDetailForTaoZhu.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div class="painting-detail-for-shuang-gou">
  3. <div
  4. class="painting-wrap"
  5. :style="{
  6. clipPath: `inset(0% 0% ${100 - AnimationProgress.value}% 0%)`,
  7. }"
  8. >
  9. <img
  10. class="painting-border"
  11. src="@/assets/images/painting-border-new.png"
  12. alt=""
  13. draggable="false"
  14. >
  15. <img
  16. ref="paintingEl"
  17. class="painting"
  18. :src="imgUrlSmall"
  19. alt=""
  20. draggable="false"
  21. >
  22. <Transition name="fade-out">
  23. <img
  24. v-show="isAnimating"
  25. class="bottom-border-for-animation"
  26. :style="{
  27. bottom: `${100 - AnimationProgress.value}%`,
  28. }"
  29. src="@/assets/images/painting-border-bottom.png"
  30. alt=""
  31. draggable="false"
  32. >
  33. </Transition>
  34. </div>
  35. <div
  36. class="bottom-text"
  37. :style="{
  38. opacity: isAnimating ? AnimationProgress.value / 100 : 1,
  39. }"
  40. >
  41. <p class="size">
  42. 163.3×103.1厘米
  43. </p>
  44. <p class="location">
  45. 台北故宫博物院藏
  46. </p>
  47. </div>
  48. <div
  49. class="right-text"
  50. :style="{
  51. opacity: isAnimating ? AnimationProgress.value / 100 : 1,
  52. }"
  53. >
  54. <img
  55. class="title"
  56. src="@/assets/images/title-tao-zhu.png"
  57. alt=""
  58. draggable="false"
  59. >
  60. <p class="subtitle subtitle-1">
  61. <span>轴</span> <span>绢本</span> <span>设色</span>
  62. </p>
  63. <p class="subtitle subtitle-2">
  64. <span>宋</span> <span>佚名</span>
  65. </p>
  66. </div>
  67. <button
  68. class="view-img"
  69. :style="{
  70. opacity: isAnimating ? AnimationProgress.value / 100 : 1,
  71. }"
  72. @click="showBigPainting"
  73. >
  74. <img
  75. class=""
  76. src="@/assets/images/painting-box-img/big-view.png"
  77. alt=""
  78. draggable="false"
  79. >
  80. </button>
  81. <BtnBack
  82. @click="router.go(-1)"
  83. />
  84. </div>
  85. </template>
  86. <script setup>
  87. import { ref, computed, watch, onMounted, inject, onUnmounted } from "vue"
  88. import { useRoute, useRouter } from "vue-router"
  89. import { useStore } from "vuex"
  90. import TWEEN from '@tweenjs/tween.js'
  91. import { api as viewerApi } from 'v-viewer'
  92. import { useWindowSize } from "@vueuse/core"
  93. const route = useRoute()
  94. const router = useRouter()
  95. const store = useStore()
  96. const $env = inject('$env')
  97. const windowHeightDesign = 1080 - 71 - 37 // 设计稿里视口高度。注意要减去上下边栏
  98. const { width: windowWidth, height: windowHeight } = useWindowSize()
  99. const isAnimating = ref(true)
  100. /** 卷轴展开动画的tweening */
  101. const AnimationProgress = ref({
  102. value: 7
  103. })
  104. const tween = new TWEEN.Tween(AnimationProgress.value)
  105. tween.to({
  106. value: 100,
  107. }, 3000)
  108. tween.easing(TWEEN.Easing.Cubic.InOut)
  109. let animationRequestId = null
  110. const animate = () => {
  111. animationRequestId = requestAnimationFrame(animate)
  112. TWEEN.update()
  113. }
  114. // tween.onUpdate(function (object) {
  115. // console.log(object.value)
  116. // })
  117. onMounted(() => {
  118. tween.start()
  119. animate()
  120. })
  121. tween.onComplete(() => {
  122. isAnimating.value = false
  123. cancelAnimationFrame(animationRequestId)
  124. })
  125. onUnmounted(() => {
  126. tween.stop()
  127. cancelAnimationFrame(animationRequestId)
  128. })
  129. const imgUrlSmall = `${$env.BASE_URL}configMultiMedia/paintings-small/桃竹双凫图.jpg`
  130. const imgUrl = `${$env.BASE_URL}configMultiMedia/paintings/桃竹双凫图.jpg`
  131. function showBigPainting() {
  132. viewerApi({
  133. images: [imgUrl],
  134. })
  135. }
  136. </script>
  137. <style lang="less" scoped>
  138. .painting-detail-for-shuang-gou{
  139. position: absolute;
  140. left: 0;
  141. top: 0;
  142. width: 100%;
  143. height: 100%;
  144. background-image: url(@/assets/images/painting-detail-bg.jpg);
  145. background-size: cover;
  146. background-repeat: no-repeat;
  147. background-position: center center;
  148. ::-webkit-scrollbar { width: 0; height: 0; }
  149. >.painting-wrap{
  150. position: absolute;
  151. left: 50%;
  152. top: calc(16px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  153. transform: translate(-50%, 0);
  154. width: calc(500px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  155. height: calc(848px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  156. overflow: hidden;
  157. >img.painting-border{
  158. position: absolute;
  159. left: 0;
  160. top: 0;
  161. width: 100%;
  162. height: 100%;
  163. }
  164. >img.painting{
  165. position: absolute;
  166. left: 50%;
  167. top: calc(167px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  168. transform: translate(-50%, 0);
  169. width: calc(398px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  170. height: calc(602px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  171. object-fit: contain;
  172. }
  173. >img.bottom-border-for-animation{
  174. position: absolute;
  175. left: 0;
  176. width: 100%;
  177. }
  178. }
  179. >.bottom-text{
  180. position: absolute;
  181. left: 50%;
  182. bottom: calc(28px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  183. transform: translateX(-50%);
  184. >p{
  185. text-align: center;
  186. font-family: KaiTi, KaiTi;
  187. font-weight: 400;
  188. font-size: calc(24px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  189. color: #E1EDD9;
  190. line-height: calc(28px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  191. white-space: pre;
  192. margin-top: 0.2em;
  193. }
  194. }
  195. >.right-text{
  196. position: absolute;
  197. top: 50%;
  198. left: calc(50% + 351px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  199. transform: translateY(-50%);
  200. display: flex;
  201. align-items: center;
  202. >img.title{
  203. height: calc(513px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  204. }
  205. >p{
  206. font-family: KaiTi, KaiTi;
  207. font-weight: 400;
  208. font-size: calc(32px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  209. color: #E1EDD9;
  210. line-height: calc(38px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  211. writing-mode: vertical-lr;
  212. letter-spacing: 0.2em;
  213. }
  214. >p:nth-of-type(1) {
  215. margin-left: calc(30px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  216. }
  217. >p:nth-of-type(2) {
  218. margin-left: calc(12px / v-bind('windowHeightDesign') * v-bind('windowHeight'));
  219. }
  220. }
  221. >button.view-img{
  222. position: absolute;
  223. left: 35px;
  224. bottom: 55px;
  225. width: 48px;
  226. height: 48px;
  227. >img{
  228. width: 100%;
  229. height: 100%;
  230. }
  231. }
  232. }
  233. </style>