Spaces:
Running
Running
File size: 2,665 Bytes
24b47cd |
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 |
document.addEventListener('DOMContentLoaded', function() {
// Mobile menu toggle
const menuToggle = document.getElementById('menu-toggle');
const navLinks = document.querySelector('nav .hidden.md\\:flex');
menuToggle.addEventListener('click', function() {
navLinks.classList.toggle('hidden');
navLinks.classList.toggle('flex');
navLinks.classList.toggle('flex-col');
navLinks.classList.toggle('absolute');
navLinks.classList.toggle('top-full');
navLinks.classList.toggle('left-0');
navLinks.classList.toggle('w-full');
navLinks.classList.toggle('bg-black');
navLinks.classList.toggle('bg-opacity-95');
navLinks.classList.toggle('p-4');
navLinks.classList.toggle('z-50');
});
// Matrix effect
const canvas = document.getElementById('matrix');
const ctx = canvas.getContext('2d');
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
const characters = "01";
const fontSize = 14;
const columns = canvas.width / fontSize;
const drops = [];
for (let i = 0; i < columns; i++) {
drops[i] = Math.random() * -100;
}
function drawMatrix() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#10B981';
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);
if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) {
drops[i] = 0;
}
drops[i]++;
}
}
// Handle window resize
window.addEventListener('resize', function() {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
const newColumns = canvas.width / fontSize;
// Adjust drops array to new column count
if (newColumns > drops.length) {
for (let i = drops.length; i < newColumns; i++) {
drops[i] = Math.random() * -100;
}
} else if (newColumns < drops.length) {
drops.length = newColumns;
}
});
// Start the matrix animation
setInterval(drawMatrix, 33);
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault(); |