|
@@ -1,44 +1,24 @@
|
1
|
1
|
<template>
|
2
|
|
- <canvas class="fireflies"></canvas>
|
|
2
|
+ <div class="fireflies-box">
|
|
3
|
+ <div class="fireflies">
|
|
4
|
+ <div class="firefly"></div>
|
|
5
|
+ <div class="firefly"></div>
|
|
6
|
+ <div class="firefly"></div>
|
|
7
|
+ <div class="firefly"></div>
|
|
8
|
+ <div class="firefly"></div>
|
|
9
|
+ <div class="firefly"></div>
|
|
10
|
+ </div>
|
|
11
|
+ </div>
|
3
|
12
|
</template>
|
4
|
13
|
|
5
|
14
|
<script>
|
6
|
|
-import Animation from "./fireflies"
|
7
|
|
-
|
8
|
15
|
export default {
|
9
|
|
- name: 'FireFlies',
|
10
|
|
- data() {
|
11
|
|
- return {
|
12
|
|
- animation: undefined,
|
13
|
|
- deAnimation: undefined,
|
14
|
|
- }
|
15
|
|
- },
|
16
|
|
- mounted() {
|
17
|
|
- this.$nextTick(() => {
|
18
|
|
- this.animation = new Animation(this.$el, {
|
19
|
|
- count: 20,
|
20
|
|
- color: 'rgba(236, 196, 94, 1)',
|
21
|
|
- speed: 0.7,
|
22
|
|
- radius: 3
|
23
|
|
- })
|
24
|
|
- const cancelDraw = this.animation.draw();
|
25
|
|
-
|
26
|
|
- this.deAnimation = () => {
|
27
|
|
- cancelDraw();
|
28
|
|
- this.animation = undefined;
|
29
|
|
- }
|
30
|
|
- })
|
31
|
|
- },
|
32
|
|
- beforeDestroy() {
|
33
|
|
- if (this.deAnimation) {
|
34
|
|
- this.deAnimation()
|
35
|
|
- }
|
36
|
|
- }
|
|
16
|
+ name: 'FireFlies'
|
37
|
17
|
}
|
38
|
18
|
</script>
|
39
|
19
|
|
40
|
20
|
<style lang="less" scoped>
|
41
|
|
-.fireflies {
|
|
21
|
+.fireflies-box {
|
42
|
22
|
width: 100%;
|
43
|
23
|
height: 100%;
|
44
|
24
|
background: transparent;
|
|
@@ -46,5 +26,125 @@ export default {
|
46
|
26
|
position: absolute;
|
47
|
27
|
top: 0;
|
48
|
28
|
left: 0;
|
|
29
|
+
|
|
30
|
+ .fireflies {
|
|
31
|
+ position: relative;
|
|
32
|
+ width: 100%;
|
|
33
|
+ height: 100%;
|
|
34
|
+ .firefly {
|
|
35
|
+ position:absolute;
|
|
36
|
+ top:50%;
|
|
37
|
+ left:50%;
|
|
38
|
+ width:0.3em;
|
|
39
|
+ height:0.3em;
|
|
40
|
+ background-color:rgb(255, 244, 48);
|
|
41
|
+ border-radius:50%;
|
|
42
|
+ box-shadow:0 0 1.4em rgb(200, 244, 66);
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ .fly1 {
|
|
46
|
+ animation: flight1 7s ease-in-out alternate infinite;
|
|
47
|
+ }
|
|
48
|
+ .fly2 {
|
|
49
|
+ animation: flight2 9s ease-in-out alternate infinite;
|
|
50
|
+ }
|
|
51
|
+ .fly3 {
|
|
52
|
+ animation: flight3 8s ease-in-out alternate infinite;
|
|
53
|
+ }
|
|
54
|
+ .fly4 {
|
|
55
|
+ animation: flight4 8s ease-in-out alternate infinite;
|
|
56
|
+ }
|
|
57
|
+ .fly5 {
|
|
58
|
+ animation: flight5 6s ease-in-out alternate infinite;
|
|
59
|
+ }
|
|
60
|
+ .fly6 {
|
|
61
|
+ animation:flight6 9s ease-in-out alternate infinite;
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ @keyframes shake {
|
|
66
|
+ 0% {
|
|
67
|
+ opacity: 0.1;
|
|
68
|
+ }
|
|
69
|
+ 30% {
|
|
70
|
+ opacity: 1;
|
|
71
|
+ width: 0.5em;
|
|
72
|
+ height: 0.5em;
|
|
73
|
+ }
|
|
74
|
+ 70% {
|
|
75
|
+ opacity: 0.7;
|
|
76
|
+ width: 0.4em;
|
|
77
|
+ height: 0.4em;
|
|
78
|
+ }
|
|
79
|
+ 100% {
|
|
80
|
+ opacity: 0;
|
|
81
|
+ }
|
|
82
|
+ }
|
|
83
|
+
|
|
84
|
+ @keyframes flight1 {
|
|
85
|
+ 0% {
|
|
86
|
+ top: 50%;
|
|
87
|
+ left: 50%;
|
|
88
|
+ opacity: 0.1;
|
|
89
|
+ }
|
|
90
|
+ 10% {
|
|
91
|
+ top: 40%;
|
|
92
|
+ left: 40%;
|
|
93
|
+ opacity:0.5;
|
|
94
|
+ width:0.4em;
|
|
95
|
+ height:0.4em;
|
|
96
|
+ }
|
|
97
|
+ 20% {
|
|
98
|
+ top: 32%;
|
|
99
|
+ left: 35%;
|
|
100
|
+ opacity: 1;
|
|
101
|
+ }
|
|
102
|
+ 30% {
|
|
103
|
+ top: 25%;
|
|
104
|
+ left: 25%;
|
|
105
|
+ opacity:1;
|
|
106
|
+ width:0.1em;
|
|
107
|
+ height:0.1em;
|
|
108
|
+ }
|
|
109
|
+ 40% {
|
|
110
|
+ top: 20%;
|
|
111
|
+ left: 20%;
|
|
112
|
+ opacity: 1;
|
|
113
|
+ }
|
|
114
|
+ 60% {
|
|
115
|
+ top: 25%;
|
|
116
|
+ left: 16%;
|
|
117
|
+ opacity: 0.5;
|
|
118
|
+ width:0.4em;
|
|
119
|
+ height:0.4em;
|
|
120
|
+ }
|
|
121
|
+ 70% {
|
|
122
|
+ top: 10%;
|
|
123
|
+ left: 10%;
|
|
124
|
+ opacity:0.1;
|
|
125
|
+ width:0.3em;
|
|
126
|
+ height:0.3em;
|
|
127
|
+ }
|
|
128
|
+ 100% {
|
|
129
|
+ top:5%;
|
|
130
|
+ left:5%;
|
|
131
|
+ opacity:0;
|
|
132
|
+ }
|
|
133
|
+ }
|
|
134
|
+ @keyframes flight2 {
|
|
135
|
+
|
|
136
|
+ }
|
|
137
|
+ @keyframes flight3 {
|
|
138
|
+
|
|
139
|
+ }
|
|
140
|
+ @keyframes flight4 {
|
|
141
|
+
|
|
142
|
+ }
|
|
143
|
+ @keyframes flight5 {
|
|
144
|
+
|
|
145
|
+ }
|
|
146
|
+ @keyframes flight6 {
|
|
147
|
+
|
|
148
|
+ }
|
49
|
149
|
}
|
50
|
150
|
</style>
|