常用的弹窗动画效果

移动端开发中,经常会用到小弹窗提示,为了实现项目的统一化,使其具有一致的表现,会将一类的表现进行统一,本文以弹窗提示的动画效果为主题记录

弹跳(抖动放大出现)

1
2
3
<div class="mask bounce-in" v-show="isUploading">
我是一个弹窗
</div>
1
2
3
4
5
6
7
8
9
<script>
export default{
data() {
return{
isUploading: false
}
}
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
.mask{
background: rgba(0, 0, 0, 0.7);
position: fixed;
left: 0;
right: 0;
bottom: 10%;
margin: auto;
}
.bounce-in {
-webkit-animation: bounce-in .3s linear;
animation: bounce-in .3s linear
}
@-webkit-keyframes bounce-in {
0% {
-webkit-transform: scale(.5);
transform: scale(.5)
}

45% {
-webkit-transform: scale(1.05);
transform: scale(1.05)
}

80% {
-webkit-transform: scale(.95);
transform: scale(.95)
}

to {
-webkit-transform: scale(1);
transform: scale(1)
}
}

@keyframes bounce-in {
0% {
-webkit-transform: scale(.5);
transform: scale(.5)
}

45% {
-webkit-transform: scale(1.05);
transform: scale(1.05)
}

80% {
-webkit-transform: scale(.95);
transform: scale(.95)
}

to {
-webkit-transform: scale(1);
transform: scale(1)
}
}

隐私政策的摇摆效果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
.shaking {
animation: shaking-ani 0.35s linear;
}
@keyframes shaking-ani {
0% {
-webkit-transform: translateX(5px);
transform: translateX(5px);
}
20% {
-webkit-transform: translateX(-5px);
transform: translateX(-5px);
}

40% {
-webkit-transform: translateX(5px);
transform: translateX(5px);
}

60% {
-webkit-transform: translateX(-5px);
transform: translateX(-5px);
}
80% {
-webkit-transform: translateX(5px);
transform: translateX(5px);
}

to {
-webkit-transform: translateX(0);
transform: translateX(0);
}
}

项目中会用到的动画

将动画效果放入到common.css中就可以给对应的容器添加类名直接使用了哦

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
.bounce-in {
-webkit-animation: bounce-in .3s linear;
animation: bounce-in .3s linear
}

.bounce-leave {
-webkit-animation: zoom-out .25s linear;
animation: zoom-out .25s linear
}

.zoom-enter,
.zoom-leave-to {
opacity: .01;
-webkit-transform: scale(.75);
transform: scale(.75)
}

.zoom-enter-active {
-webkit-transition: all .3s cubic-bezier(.215, .61, .355, 1);
transition: all .3s cubic-bezier(.215, .61, .355, 1)
}

.zoom-leave-active {
-webkit-transition: all .25s linear;
transition: all .25s linear
}

.punch-enter,
.punch-leave-to {
opacity: .01;
-webkit-transform: scale(1.35);
transform: scale(1.35)
}

.punch-enter-active {
-webkit-transition: all .3s cubic-bezier(.215, .61, .355, 1);
transition: all .3s cubic-bezier(.215, .61, .355, 1)
}

.punch-leave-active {
-webkit-transition: all .25s linear;
transition: all .25s linear
}

.slide-up-enter,
.slide-up-leave-to {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0)
}

.slide-up-enter-active {
-webkit-transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1), -webkit-transform .3s cubic-bezier(.165, .84, .44, 1)
}

.slide-up-leave-active {
-webkit-transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1), -webkit-transform .25s cubic-bezier(.165, .84, .44, 1)
}

.slide-right-enter,
.slide-right-leave-to {
-webkit-transform: translate3d(-100%, 0, 0);
transform: translate3d(-100%, 0, 0)
}

.slide-right-enter-active {
-webkit-transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1), -webkit-transform .3s cubic-bezier(.165, .84, .44, 1)
}

.slide-right-leave-active {
-webkit-transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1), -webkit-transform .25s cubic-bezier(.165, .84, .44, 1)
}

.slide-left-enter,
.slide-left-leave-to {
-webkit-transform: translate3d(100%, 0, 0);
transform: translate3d(100%, 0, 0)
}

.slide-left-enter-active {
-webkit-transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1), -webkit-transform .3s cubic-bezier(.165, .84, .44, 1)
}

.slide-left-leave-active {
-webkit-transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1), -webkit-transform .25s cubic-bezier(.165, .84, .44, 1)
}

.slide-down-enter,
.slide-down-leave-to {
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0)
}

.slide-down-enter-active {
-webkit-transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1);
transition: transform .3s cubic-bezier(.165, .84, .44, 1), -webkit-transform .3s cubic-bezier(.165, .84, .44, 1)
}

.slide-down-leave-active {
-webkit-transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: -webkit-transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1);
transition: transform .25s cubic-bezier(.165, .84, .44, 1), -webkit-transform .25s cubic-bezier(.165, .84, .44, 1)
}

.fade-enter,
.fade-leave-to {
opacity: .01
}

.fade-enter-active {
-webkit-transition: opacity .3s cubic-bezier(.215, .61, .355, 1);
transition: opacity .3s cubic-bezier(.215, .61, .355, 1)
}

.fade-leave-active {
-webkit-transition: opacity .25s linear;
transition: opacity .25s linear
}

.fade-up-enter,
.fade-up-leave-to {
opacity: .01;
-webkit-transform: translate3d(0, 20%, 0);
transform: translate3d(0, 20%, 0)
}

.fade-up-enter-active {
-webkit-transition: all .3s cubic-bezier(.215, .61, .355, 1);
transition: all .3s cubic-bezier(.215, .61, .355, 1)
}

.fade-up-leave-active {
-webkit-transition: all .25s linear;
transition: all .25s linear
}

.fade-down-enter,
.fade-down-leave-to {
opacity: .01;
-webkit-transform: translate3d(0, -20%, 0);
transform: translate3d(0, -20%, 0)
}

.fade-down-enter-active {
-webkit-transition: all .3s cubic-bezier(.215, .61, .355, 1);
transition: all .3s cubic-bezier(.215, .61, .355, 1)
}

.fade-down-leave-active {
-webkit-transition: all .25s linear;
transition: all .25s linear
}

.fade-right-enter,
.fade-right-leave-to {
opacity: .01;
-webkit-transform: translate3d(-20%, 0, 0);
transform: translate3d(-20%, 0, 0)
}

.fade-right-enter-active {
-webkit-transition: all .3s cubic-bezier(.215, .61, .355, 1);
transition: all .3s cubic-bezier(.215, .61, .355, 1)
}

.fade-right-leave-active {
-webkit-transition: all .25s linear;
transition: all .25s linear
}

.fade-left-enter,
.fade-left-leave-to {
opacity: .01;
-webkit-transform: translate3d(20%, 0, 0);
transform: translate3d(20%, 0, 0)
}

.fade-left-enter-active {
-webkit-transition: all .3s cubic-bezier(.215, .61, .355, 1);
transition: all .3s cubic-bezier(.215, .61, .355, 1)
}

.fade-left-leave-active {
-webkit-transition: all .25s linear;
transition: all .25s linear
}

.fly-enter-active {
-webkit-animation: fly-in .6s;
animation: fly-in .6s;
-webkit-animation-timing-function: cubic-bezier(.215, .61, .355, 1);
animation-timing-function: cubic-bezier(.215, .61, .355, 1)
}

.fly-leave-active {
-webkit-animation: zoom-out .25s;
animation: zoom-out .25s
}

@-webkit-keyframes fly-in {
0% {
opacity: .5;
-webkit-transform: scale(.5) translate3d(0, 50px, 0);
transform: scale(.5) translate3d(0, 50px, 0)
}

45% {
opacity: 1;
-webkit-transform: scale(1.05) translate3d(0, -50px, 0);
transform: scale(1.05) translate3d(0, -50px, 0)
}

to {
-webkit-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0)
}
}

@keyframes fly-in {
0% {
opacity: .5;
-webkit-transform: scale(.5) translate3d(0, 50px, 0);
transform: scale(.5) translate3d(0, 50px, 0)
}

45% {
opacity: 1;
-webkit-transform: scale(1.05) translate3d(0, -50px, 0);
transform: scale(1.05) translate3d(0, -50px, 0)
}

to {
-webkit-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0)
}
}

@-webkit-keyframes bounce-in {
0% {
-webkit-transform: scale(.5);
transform: scale(.5)
}

45% {
-webkit-transform: scale(1.05);
transform: scale(1.05)
}

80% {
-webkit-transform: scale(.95);
transform: scale(.95)
}

to {
-webkit-transform: scale(1);
transform: scale(1)
}
}

@keyframes bounce-in {
0% {
-webkit-transform: scale(.5);
transform: scale(.5)
}

45% {
-webkit-transform: scale(1.05);
transform: scale(1.05)
}

80% {
-webkit-transform: scale(.95);
transform: scale(.95)
}

to {
-webkit-transform: scale(1);
transform: scale(1)
}
}

@-webkit-keyframes zoom-out {
to {
opacity: .01;
-webkit-transform: scale(.75);
transform: scale(.75)
}
}

@keyframes zoom-out {
to {
opacity: .01;
-webkit-transform: scale(.75);
transform: scale(.75)
}
}

本文灵感源于mand-mobile-UI,详情请参考Transition 动画

更新于

请我喝[茶]~( ̄▽ ̄)~*

Ming Liu 微信支付

微信支付

Ming Liu 支付宝

支付宝

Ming Liu 贝宝

贝宝