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
<!--
* 变形动画
-->
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import anime from 'animejs/lib/anime.es.js';
const containerRef = ref<any>(null);
onMounted(() => {
for (let i = 1; i <= 100; i++) {
const dot = document.createElement('div');
dot.classList.add('element');
containerRef.value.appendChild(dot);
}
const dotAll = document.querySelectorAll('.element');
const animation = anime.timeline({
targets: dotAll,
easing: 'easeInOutExpo',
delay: anime.stagger(100, { grid: [10, 10], from: 'center' }),
loop: true,
});
animation
.add({
rotateZ: 180,
translateY: anime.stagger(-20, {
grid: [10, 10],
from: 'center',
axis: 'y',
}),
translateX: anime.stagger(-20, {
grid: [10, 10],
from: 'center',
axis: 'x',
}),
opacity: 1,
})
.add({
borderRadius: 50,
})
.add({
scale: 0.2,
opacity: 0.2,
})
.add({
rotateZ: 180,
translateY: anime.stagger(0, {
grid: [10, 10],
from: 'center',
axis: 'y',
}),
translateX: anime.stagger(0, {
grid: [10, 10],
from: 'center',
axis: 'x',
}),
opacity: 1,
})
.add({
scale: 1,
borderRadius: 0,
})
.add({
rotateZ: -90,
});
});
</script>
<template>
<div class="box">
<div class="container" ref="containerRef"></div>
</div>
</template>
<style lang="scss" scoped>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:deep(.container .element) {
position: relative;
width: 40px;
height: 40px;
background-color: #fff;
scale: 0.75;
}
.box {
width: 100%;
height: 100%;
background-color: #222;
display: flex;
justify-content: center;
align-items: center;
}
.container {
position: relative;
min-width: 400px;
width: 400px;
height: 400px;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
</style>