张延森 3 年之前
父節點
當前提交
85edfca1b2
共有 3 個檔案被更改,包括 77 行新增11 行删除
  1. 二進制
      src/assets/BackImage/cloud.png
  2. 3
    1
      src/components/BackPage.vue
  3. 74
    10
      src/components/Cloud.vue

二進制
src/assets/BackImage/cloud.png 查看文件


+ 3
- 1
src/components/BackPage.vue 查看文件

4
     <!-- :style="HomeStyle" -->
4
     <!-- :style="HomeStyle" -->
5
     <div class="index-image">
5
     <div class="index-image">
6
       <img :src="backHome" class="bg-image" />
6
       <img :src="backHome" class="bg-image" />
7
-      <CloudVue />
7
+      <CloudVue :scale="1.2" top="10vh" />
8
+      <CloudVue :scale="1" top="30vh" right="0" direction="left" :delay="1" />
9
+      <CloudVue :scale="0.8" top="40vh" :delay="1.8" />
8
       <slot></slot>
10
       <slot></slot>
9
       <!-- <div class="GrassGIFBox">
11
       <!-- <div class="GrassGIFBox">
10
         <GrassGIF />
12
         <GrassGIF />

+ 74
- 10
src/components/Cloud.vue 查看文件

1
 <template>
1
 <template>
2
-  <div class="motion-cloud">
3
-    <img :src="cloudImage" alt="">
2
+  <div
3
+    class="motion-cloud"
4
+    :class="{ ['cloud-left']: 'left' === direction, ['cloud-right']: 'right' === direction }"
5
+    :style="cloudStyle"
6
+  >
7
+    <img
8
+      :src="cloudImage"
9
+      alt=""
10
+      :style="imageStyle"
11
+    >
4
   </div>
12
   </div>
5
 </template>
13
 </template>
6
 
14
 
7
 <script setup>
15
 <script setup>
16
+import { computed } from 'vue';
8
 import cloudImage from '@/assets/BackImage/cloud.png'
17
 import cloudImage from '@/assets/BackImage/cloud.png'
9
-import { onMounted } from 'vue';
10
 
18
 
11
-onMounted(() => {
12
-  console.log('---------onMounted-----')
19
+const props = defineProps({
20
+  scale: {
21
+    type: Number,
22
+    default: 1,
23
+  },
24
+  direction: {
25
+    type: String,
26
+    default: 'right'
27
+  },
28
+  delay: {
29
+    type: Number,
30
+    default: 0,
31
+  },
32
+  top: {
33
+    type: String,
34
+    default: 'auto',
35
+  },
36
+  bottom: {
37
+    type: String,
38
+    default: 'auto',
39
+  },
40
+  left: {
41
+    type: String,
42
+    default: 'auto',
43
+  },
44
+  right: {
45
+    type: String,
46
+    default: 'auto',
47
+  },
13
 })
48
 })
49
+
50
+const cloudStyle = computed(() => ({
51
+  left: props.left,
52
+  right: props.right,
53
+  top: props.top,
54
+  bottom: props.bottom,
55
+  animationDelay: `${props.delay}s`
56
+}))
57
+
58
+const imageStyle = computed(() => ({
59
+  transform: `scale(${props.scale})`,
60
+}))
61
+
14
 </script>
62
 </script>
15
 
63
 
16
 <style lang="less" scoped>
64
 <style lang="less" scoped>
17
 .motion-cloud {
65
 .motion-cloud {
66
+  position: absolute;
18
   width: 160px;
67
   width: 160px;
19
-  animation: fadefloat 120s linear infinite;
20
   animation-fill-mode: forwards;
68
   animation-fill-mode: forwards;
69
+  animation-duration: 10s;
70
+  animation-timing-function: linear;
71
+  animation-iteration-count: infinite;
72
+  opacity: 0;
73
+
74
+  &.cloud-left {
75
+    animation-name: fadefloat, flyleft;
76
+  }
21
   
77
   
78
+  &.cloud-right {
79
+    animation-name: fadefloat, flyright;
80
+  }
22
 
81
 
23
   & > img {
82
   & > img {
24
     width: 100%;
83
     width: 100%;
26
 
85
 
27
   @keyframes fadefloat {
86
   @keyframes fadefloat {
28
     0%, 100% { opacity: 0; }
87
     0%, 100% { opacity: 0; }
29
-    5%, 90% { opacity: 1; }
88
+    10%, 60% { opacity: 1; }
89
+  }
90
+
91
+  @keyframes flyleft {
92
+    from { transform: translateX(0); }
93
+    to { transform: translateX(-50%); }
30
   }
94
   }
31
 
95
 
32
-  @keyframes flyfloat {
33
-    from { transform: translateX(100%) translateZ(0); }
34
-    to { transform: translateX(-15%) translateZ(0); }
96
+  @keyframes flyright {
97
+    from { transform: translateX(0); }
98
+    to { transform: translateX(50%); }
35
   }
99
   }
36
 }
100
 }
37
 </style>
101
 </style>