|
@@ -1,24 +1,83 @@
|
1
|
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
|
12
|
</div>
|
5
|
13
|
</template>
|
6
|
14
|
|
7
|
15
|
<script setup>
|
|
16
|
+import { computed } from 'vue';
|
8
|
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
|
62
|
</script>
|
15
|
63
|
|
16
|
64
|
<style lang="less" scoped>
|
17
|
65
|
.motion-cloud {
|
|
66
|
+ position: absolute;
|
18
|
67
|
width: 160px;
|
19
|
|
- animation: fadefloat 120s linear infinite;
|
20
|
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
|
82
|
& > img {
|
24
|
83
|
width: 100%;
|
|
@@ -26,12 +85,17 @@ onMounted(() => {
|
26
|
85
|
|
27
|
86
|
@keyframes fadefloat {
|
28
|
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
|
101
|
</style>
|