index.vue 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <div class="page pg-bg pg2" parallax ref="pgRef">
  3. <div class="bg">
  4. <div>
  5. <Animate
  6. comp="img"
  7. name="animate__fadeInLeft"
  8. src="/images/pg2/content-bg.png"
  9. :ready="show"
  10. />
  11. </div>
  12. </div>
  13. <div class="content">
  14. <div>
  15. <Animate
  16. class="year"
  17. comp="img"
  18. name="animate__fadeIn"
  19. src="/images/pg2/1939年.png"
  20. delay="1000ms"
  21. :ready="show"
  22. />
  23. </div>
  24. <div>
  25. <Animate
  26. class="text1"
  27. comp="img"
  28. name="animate__fadeInUp"
  29. src="/images/pg2/text1.png"
  30. delay="2000ms"
  31. :ready="show"
  32. />
  33. </div>
  34. <div>
  35. <Animate
  36. class="text2"
  37. comp="img"
  38. name="animate__fadeIn"
  39. src="/images/pg2/text2.png"
  40. delay="3000ms"
  41. :ready="show"
  42. />
  43. </div>
  44. </div>
  45. <div class="groups abs">
  46. <div>
  47. <InkEffect class="ink-ruins" src="./images/pg2/废墟color.png" :speed="10" :active="inkActive" :clearable="true" />
  48. <img class="ruins" src="/images/pg2/废墟.png" alt />
  49. </div>
  50. </div>
  51. <div class="flower1">
  52. <div>
  53. <img :class="{'flower-fly': show}" src="/images/pg2/flower1.png" alt="" @animationend="inkActive = true" />
  54. </div>
  55. </div>
  56. <div class="flower2">
  57. <div>
  58. <img src="/images/pg2/flower2.png" alt="" />
  59. </div>
  60. </div>
  61. <div class="footer txt">
  62. 了解故事
  63. <img src="/images/pg2/箭头-右.png" alt />
  64. </div>
  65. </div>
  66. </template>
  67. <script setup>
  68. import { reactive, ref, watch } from "vue";
  69. import { useRouter } from "vue-router";
  70. import Bell from "@/components/Bell.vue";
  71. import Animate from "@/components/Animate.vue";
  72. import InkEffect from "@/components/InkEffect.vue";
  73. import Cloud from "./Cloud.vue";
  74. import Smoke from "./smoke.vue";
  75. import Flower1 from "./flower/Flower1.vue";
  76. import Flower2 from "./flower/Flower2.vue";
  77. import Flower3 from "./flower/Flower3.vue";
  78. import usePageShow from "../usePageShow";
  79. const router = useRouter();
  80. const inkActive = ref(false);
  81. const onClick = () => {
  82. router.push(`/pg2-2`);
  83. };
  84. const flowerAnimate = reactive({
  85. left: "",
  86. right: "",
  87. });
  88. let lastRatio = 0;
  89. const flowShow = ({ intersectionRatio }) => {
  90. console.log(intersectionRatio);
  91. const isIn = intersectionRatio > 0.5 && intersectionRatio > lastRatio;
  92. const isOut = intersectionRatio < 0.9 && intersectionRatio < lastRatio;
  93. if (isIn) {
  94. flowerAnimate.left = "animate__fadeInLeft";
  95. flowerAnimate.right = "animate__fadeInRight";
  96. }
  97. if (isOut) {
  98. flowerAnimate.left = "animate__fadeOutLeft";
  99. flowerAnimate.right = "animate__fadeOutRight";
  100. }
  101. lastRatio = intersectionRatio;
  102. };
  103. const [pgRef, show] = usePageShow(flowShow);
  104. watch(show, (val) => {
  105. if (!val) {
  106. inkActive.value = false;
  107. }
  108. })
  109. </script>
  110. <style lang="less" scoped>
  111. .pg2 {
  112. overflow: hidden;
  113. .bg {
  114. position: absolute;
  115. z-index: 0;
  116. width: 50%;
  117. left: 0;
  118. top: 0;
  119. & > div {
  120. position: relative;
  121. }
  122. }
  123. .content {
  124. z-index: 10;
  125. width: 80vw;
  126. margin-left: 15vw;
  127. padding-top: 80px;
  128. line-height: 2em;
  129. .year {
  130. margin-top: 40px;
  131. width: 60%;
  132. }
  133. .text1 {
  134. margin-top: 30px;
  135. width: 30%;
  136. }
  137. .text2 {
  138. margin-top: 30px;
  139. width: 60%;
  140. }
  141. .story {
  142. margin-top: 12px;
  143. width: 45%;
  144. display: block;
  145. animation-delay: 600ms;
  146. }
  147. }
  148. .groups {
  149. top: 50vh;
  150. left: 0;
  151. width: 100%;
  152. z-index: 3;
  153. & > div {
  154. position: relative;
  155. }
  156. .ruins {
  157. z-index: 2;
  158. position: relative;
  159. }
  160. .ink-ruins {
  161. position: absolute;
  162. z-index: 4;
  163. top: 0;
  164. left: 0;
  165. width: 100%;
  166. height: 100%;
  167. }
  168. }
  169. .flower1 {
  170. position: absolute;
  171. z-index: 20;
  172. width: 50%;
  173. left: 50px;
  174. top: 500px;
  175. & > div {
  176. position: relative;
  177. }
  178. img {
  179. width: 50px;
  180. }
  181. }
  182. .flower-fly {
  183. transform-origin: left bottom;
  184. animation: flower-fly 3s ease-in-out 1s forwards;
  185. }
  186. @keyframes flower-fly {
  187. 0% {
  188. transform: rotate(0) translate3d(0, 0, 0);
  189. opacity: 1;
  190. }
  191. 90% {
  192. opacity: 0;
  193. }
  194. 100% {
  195. transform: rotate(180deg) translate3d(-60vw, -6vh, 0);
  196. opacity: 0;
  197. }
  198. }
  199. .flower2 {
  200. position: absolute;
  201. z-index: 20;
  202. right: 0;
  203. top: 250px;
  204. img {
  205. width: 80px;
  206. }
  207. }
  208. .footer {
  209. left: 0;
  210. bottom: 0;
  211. position: absolute;
  212. width: 100%;
  213. text-align: center;
  214. font-size: 24px;
  215. img {
  216. width: 15px;
  217. height: 25px;
  218. display: inline;
  219. width: auto;
  220. vertical-align: text-bottom;
  221. }
  222. }
  223. }
  224. </style>