|
221 | 221 |
|
222 | 222 | .confetti { |
223 | 223 | position: fixed; |
224 | | - width: 10px; |
225 | | - height: 10px; |
226 | | - background: #ffc107; |
227 | | - animation: fall 3s linear; |
228 | 224 | z-index: 999; |
| 225 | + pointer-events: none; |
229 | 226 | } |
230 | 227 |
|
231 | 228 | @keyframes fall { |
232 | 229 | to { |
233 | | - transform: translateY(100vh) rotate(360deg); |
| 230 | + transform: translateY(100vh) rotate(720deg); |
234 | 231 | opacity: 0; |
235 | 232 | } |
236 | 233 | } |
237 | 234 |
|
| 235 | + @keyframes swing { |
| 236 | + 0%, 100% { transform: translateX(0); } |
| 237 | + 50% { transform: translateX(40px); } |
| 238 | + } |
| 239 | + |
238 | 240 | .stats { |
239 | 241 | display: grid; |
240 | 242 | grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); |
@@ -404,17 +406,31 @@ <h2>🎉 ¡Gracias por participar!</h2> |
404 | 406 | } |
405 | 407 |
|
406 | 408 | function createConfetti() { |
407 | | - const colors = ['#ffc107', '#2d9f5f', '#6f7b86', '#d16d1d', '#ff6b9d']; |
408 | | - for (let i = 0; i < 50; i++) { |
| 409 | + const colors = ['#ffc107', '#2d9f5f', '#6f7b86', '#d16d1d', '#ff6b9d', '#e91e63', '#9c27b0', '#2196f3', '#ff5722', '#4caf50']; |
| 410 | + const shapes = ['square', 'circle', 'rectangle']; |
| 411 | + |
| 412 | + for (let i = 0; i < 100; i++) { |
409 | 413 | setTimeout(() => { |
410 | 414 | const confetti = document.createElement('div'); |
411 | 415 | confetti.className = 'confetti'; |
412 | | - confetti.style.left = Math.random() * 100 + 'vw'; |
| 416 | + |
| 417 | + const size = Math.random() * 15 + 8; |
| 418 | + const duration = Math.random() * 2 + 2; |
| 419 | + const left = Math.random() * 100; |
| 420 | + const shape = shapes[Math.floor(Math.random() * shapes.length)]; |
| 421 | + |
| 422 | + confetti.style.left = left + 'vw'; |
| 423 | + confetti.style.top = '-20px'; |
413 | 424 | confetti.style.background = colors[Math.floor(Math.random() * colors.length)]; |
414 | | - confetti.style.animationDelay = Math.random() * 0.5 + 's'; |
| 425 | + confetti.style.width = (shape === 'rectangle' ? size * 1.5 : size) + 'px'; |
| 426 | + confetti.style.height = (shape === 'rectangle' ? size * 0.5 : size) + 'px'; |
| 427 | + confetti.style.borderRadius = shape === 'circle' ? '50%' : (Math.random() > 0.5 ? '2px' : '0'); |
| 428 | + confetti.style.animation = `fall ${duration}s linear forwards`; |
| 429 | + confetti.style.opacity = Math.random() * 0.5 + 0.5; |
| 430 | + |
415 | 431 | document.body.appendChild(confetti); |
416 | | - setTimeout(() => confetti.remove(), 3000); |
417 | | - }, i * 30); |
| 432 | + setTimeout(() => confetti.remove(), duration * 1000); |
| 433 | + }, i * 20); |
418 | 434 | } |
419 | 435 | } |
420 | 436 |
|
|
0 commit comments