-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimations.js
145 lines (131 loc) · 4.77 KB
/
animations.js
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
function createFirework(winner) {
const fireworkCount = 20;
const particleCount = 50;
const colors = winner === 'O' ? ['#ff4136', '#ff5a1b', '#ff7f00'] : ['#0074d9', '#7fbfff', '#3996cc'];
animationInProgress = true;
for (let f = 0; f < fireworkCount; f++) {
const firework = document.createElement('div');
firework.className = 'firework';
document.body.appendChild(firework);
// Position aléatoire sur l'écran
const startX = Math.random() * window.innerWidth;
const startY = Math.random() * window.innerHeight;
firework.style.left = `${startX}px`;
firework.style.top = `${startY}px`;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
particle.style.borderRadius = '50%';
particle.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
firework.appendChild(particle);
const angle = Math.random() * Math.PI * 2;
const distance = 50 + Math.random() * 150; // Augmenté la distance maximale
anime({
targets: particle,
translateX: Math.cos(angle) * distance,
translateY: Math.sin(angle) * distance,
scale: [1, 0],
opacity: [1, 0],
easing: 'easeOutExpo',
duration: 2000 + Math.random() * 1000,
delay: Math.random() * 1000,
complete: function () {
particle.remove();
}
});
}
setTimeout(() => {
firework.remove();
animationInProgress = false;
}, 3000);
}
}
function createDrawAnimation() {
animationInProgress = true;
const animationContainer = document.createElement('div');
animationContainer.style.position = 'fixed';
animationContainer.style.top = '0';
animationContainer.style.left = '0';
animationContainer.style.width = '100%';
animationContainer.style.height = '100%';
animationContainer.style.pointerEvents = 'none';
animationContainer.style.zIndex = '1000';
document.body.appendChild(animationContainer);
const redCircle = createSVGSymbol('O');
redCircle.style.position = 'absolute';
redCircle.style.left = '0';
redCircle.style.bottom = '125px';
redCircle.style.width = '100px';
redCircle.style.height = '100px';
const circleElement = redCircle.querySelector('.o-symbol');
circleElement.style.stroke = '#ff4136';
circleElement.style.strokeWidth = '12';
circleElement.style.fill = 'none';
animationContainer.appendChild(redCircle);
const blueX = createSVGSymbol('X');
blueX.style.position = 'absolute';
blueX.style.right = '0';
blueX.style.bottom = '125px';
blueX.style.width = '100px';
blueX.style.height = '100px';
blueX.querySelectorAll('.x-symbol').forEach(line => {
line.style.stroke = '#0074d9';
line.style.strokeWidth = '12';
line.style.strokeLinecap = 'round';
});
animationContainer.appendChild(blueX);
const handshakeIcon = document.createElement('div');
handshakeIcon.innerHTML = '🤝';
handshakeIcon.style.position = 'absolute';
handshakeIcon.style.fontSize = '40px';
handshakeIcon.style.left = '50%';
handshakeIcon.style.bottom = '150px';
handshakeIcon.style.transform = 'translateX(-50%) scale(0)';
handshakeIcon.style.opacity = '0';
animationContainer.appendChild(handshakeIcon);
anime.timeline({
easing: 'easeOutQuad',
duration: 1000,
complete: function() {
setTimeout(() => {
animationContainer.remove();
animationInProgress = false;
}, 3000);
}
}).add({
targets: redCircle,
translateX: window.innerWidth / 2 - 115
}).add({
targets: blueX,
translateX: -window.innerWidth / 2 + 115
}, '-=1000').add({
targets: handshakeIcon,
scale: 1,
opacity: 1,
duration: 500
}).add({
targets: handshakeIcon,
translateY: -20,
direction: 'alternate',
duration: 300,
loop: 2
}).add({
targets: handshakeIcon,
translateY: 10,
direction: 'alternate',
duration: 300,
loop: 2
}).add({
targets: handshakeIcon,
translateY: -20,
direction: 'alternate',
duration: 300,
loop: 2
}).add({
targets: handshakeIcon,
translateY: 2,
direction: 'alternate',
duration: 300,
loop: 2
});
}