mgbam commited on
Commit
e60640d
·
verified ·
1 Parent(s): 3703d2e

Update genesis/static/animation.js

Browse files
Files changed (1) hide show
  1. genesis/static/animation.js +49 -66
genesis/static/animation.js CHANGED
@@ -1,70 +1,53 @@
1
- // ===== MOLECULAR PARTICLE ANIMATION =====
2
-
3
- // Create a canvas background
4
- const canvas = document.createElement('canvas');
5
- canvas.id = 'moleculeCanvas';
6
- document.body.appendChild(canvas);
7
- const ctx = canvas.getContext('2d');
8
-
9
- // Resize canvas to full window
10
- function resizeCanvas() {
11
- canvas.width = window.innerWidth;
12
- canvas.height = window.innerHeight;
13
- }
14
- window.addEventListener('resize', resizeCanvas);
15
- resizeCanvas();
16
-
17
- // Create particles
18
- let particles = [];
19
- const numParticles = 80;
20
-
21
- for (let i = 0; i < numParticles; i++) {
22
- particles.push({
23
- x: Math.random() * canvas.width,
24
- y: Math.random() * canvas.height,
25
- radius: Math.random() * 4 + 1,
26
- color: Math.random() > 0.5 ? '#00ff88' : '#ffaa00',
27
- speedX: (Math.random() - 0.5) * 1.5,
28
- speedY: (Math.random() - 0.5) * 1.5
29
  });
30
  }
31
-
32
- // Animation loop
33
- function animate() {
34
- ctx.clearRect(0, 0, canvas.width, canvas.height);
35
-
36
- // Draw and move particles
37
- particles.forEach((p, index) => {
38
- p.x += p.speedX;
39
- p.y += p.speedY;
40
-
41
- // Bounce off edges
42
- if (p.x < 0 || p.x > canvas.width) p.speedX *= -1;
43
- if (p.y < 0 || p.y > canvas.height) p.speedY *= -1;
44
-
45
- // Draw particle
46
- ctx.beginPath();
47
- ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
48
- ctx.fillStyle = p.color;
49
- ctx.fill();
50
-
51
- // Connect lines if particles are close
52
- for (let j = index + 1; j < particles.length; j++) {
53
- let dx = particles[j].x - p.x;
54
- let dy = particles[j].y - p.y;
55
- let distance = Math.sqrt(dx * dx + dy * dy);
56
- if (distance < 120) {
57
- ctx.beginPath();
58
- ctx.moveTo(p.x, p.y);
59
- ctx.lineTo(particles[j].x, particles[j].y);
60
- ctx.strokeStyle = p.color === '#00ff88' ? '#00ff88aa' : '#ffaa00aa';
61
- ctx.lineWidth = 0.5;
62
- ctx.stroke();
63
- }
64
- }
65
  });
66
-
67
- requestAnimationFrame(animate);
68
  }
69
-
70
- animate();
 
 
 
 
 
 
 
 
 
 
 
1
+ // Smooth fade-in for panels
2
+ document.addEventListener("DOMContentLoaded", () => {
3
+ const blocks = document.querySelectorAll(".gr-block");
4
+ blocks.forEach((block, index) => {
5
+ block.style.opacity = 0;
6
+ block.style.transform = "translateY(20px)";
7
+ setTimeout(() => {
8
+ block.style.transition = "all 0.6s ease";
9
+ block.style.opacity = 1;
10
+ block.style.transform = "translateY(0)";
11
+ }, index * 100); // Staggered load
12
+ });
13
+ });
14
+
15
+ // Button glow pulse
16
+ function pulseButtons() {
17
+ const buttons = document.querySelectorAll("button, .gr-button");
18
+ buttons.forEach(btn => {
19
+ btn.addEventListener("mouseenter", () => {
20
+ btn.style.boxShadow = "0 0 20px rgba(255, 145, 0, 0.8)";
21
+ });
22
+ btn.addEventListener("mouseleave", () => {
23
+ btn.style.boxShadow = "0 0 10px rgba(0, 255, 157, 0.4)";
24
+ });
 
 
 
 
25
  });
26
  }
27
+ pulseButtons();
28
+
29
+ // Graph animation on load
30
+ function animateGraphs() {
31
+ const graphs = document.querySelectorAll(".graph-container");
32
+ graphs.forEach(graph => {
33
+ graph.style.opacity = 0;
34
+ graph.style.transform = "scale(0.95)";
35
+ setTimeout(() => {
36
+ graph.style.transition = "all 0.5s ease";
37
+ graph.style.opacity = 1;
38
+ graph.style.transform = "scale(1)";
39
+ }, 300);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  });
 
 
41
  }
42
+ animateGraphs();
43
+
44
+ // Auto-refresh glow for updated sections
45
+ function glowOnUpdate(selector) {
46
+ const element = document.querySelector(selector);
47
+ if (element) {
48
+ element.style.boxShadow = "0 0 25px rgba(0, 255, 157, 0.8)";
49
+ setTimeout(() => {
50
+ element.style.boxShadow = "";
51
+ }, 1000);
52
+ }
53
+ }