-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
122 lines (99 loc) · 4.02 KB
/
Copy pathscript.js
File metadata and controls
122 lines (99 loc) · 4.02 KB
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
document.addEventListener('DOMContentLoaded', () => {
// Mobile Navigation Toggle
const menuToggle = document.querySelector('.menu-toggle');
const navLinks = document.querySelector('.nav-links');
menuToggle.addEventListener('click', () => {
navLinks.classList.toggle('active');
// Icon toggle
const icon = menuToggle.querySelector('ion-icon');
if (navLinks.classList.contains('active')) {
icon.setAttribute('name', 'close-outline');
} else {
icon.setAttribute('name', 'menu-outline');
}
});
// Smooth Scrolling for Anchor Links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
// Close mobile menu if open
navLinks.classList.remove('active');
const icon = menuToggle.querySelector('ion-icon');
if (icon) icon.setAttribute('name', 'menu-outline');
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
});
}
});
});
// Simple Intersection Observer for Fade-in animations
const observerOptions = {
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
// observer.unobserve(entry.target); // Keep animating or not? Let's leave it.
}
});
}, observerOptions);
const sections = document.querySelectorAll('.section, .hero');
sections.forEach(section => {
section.classList.add('fade-in-section'); // Add initial class via JS to not hide content if JS disabled
observer.observe(section);
});
});
// Matrix Digital Rain Animation
const canvas = document.getElementById('bg-canvas');
const ctx = canvas.getContext('2d');
// Resize Canvas
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
init();
});
// Matrix Characters (Katakana + Latin + Nums)
const characters = 'アィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモヤユヨラリルレロワヰヱヲンヴヵヶ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const fontSize = 16;
let columns;
let drops;
function init() {
columns = Math.floor(canvas.width / fontSize);
drops = [];
for (let i = 0; i < columns; i++) {
drops[i] = 1; // Start at top
}
}
function draw() {
// Translucent black background to show trail effect
ctx.fillStyle = 'rgba(10, 25, 47, 0.05)'; // Dark blue bg with low opacity
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#0F0'; // Green text (Matrix style) - Or use Theme Cyan: '#64ffda'
// Let's go with Theme Cyan for consistency? No, user wants best cyber look. Green is classic matrix.
// But Cyan fits the site theme better. Let's use the site accent color '#64ffda'.
ctx.fillStyle = '#64ffda';
ctx.font = fontSize + 'px monospace';
for (let i = 0; i < drops.length; i++) {
const text = characters.charAt(Math.floor(Math.random() * characters.length));
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
// Randomly reset drop to top
if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) {
drops[i] = 0;
}
drops[i]++;
}
}
// Animation Loop
function animate() {
requestAnimationFrame(animate);
draw();
}
// Start
init();
animate();