mobile optimisation
This commit is contained in:
@@ -103,6 +103,9 @@
|
||||
|
||||
// Initialize
|
||||
function init() {
|
||||
// Skip animation on mobile/touch devices for performance
|
||||
if (window.innerWidth <= 768 || ('ontouchstart' in window)) return;
|
||||
|
||||
canvas = document.getElementById('hexCanvas');
|
||||
if (!canvas) return;
|
||||
|
||||
|
||||
@@ -6,7 +6,51 @@
|
||||
*/
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
|
||||
// ==========================================
|
||||
// MOBILE HAMBURGER MENU
|
||||
// ==========================================
|
||||
|
||||
function initHamburgerMenu() {
|
||||
const hamburgerBtn = document.getElementById('hamburgerBtn');
|
||||
const mobileNavOverlay = document.getElementById('mobileNavOverlay');
|
||||
if (!hamburgerBtn || !mobileNavOverlay) return;
|
||||
|
||||
function openNav() {
|
||||
mobileNavOverlay.style.display = 'flex';
|
||||
requestAnimationFrame(() => {
|
||||
mobileNavOverlay.classList.add('open');
|
||||
});
|
||||
hamburgerBtn.classList.add('open');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
function closeNav() {
|
||||
mobileNavOverlay.classList.remove('open');
|
||||
hamburgerBtn.classList.remove('open');
|
||||
document.body.style.overflow = '';
|
||||
setTimeout(() => {
|
||||
if (!mobileNavOverlay.classList.contains('open')) {
|
||||
mobileNavOverlay.style.display = 'none';
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
hamburgerBtn.addEventListener('click', () => {
|
||||
if (mobileNavOverlay.classList.contains('open')) {
|
||||
closeNav();
|
||||
} else {
|
||||
openNav();
|
||||
}
|
||||
});
|
||||
|
||||
mobileNavOverlay.querySelectorAll('.mobile-nav-link').forEach(link => {
|
||||
link.addEventListener('click', closeNav);
|
||||
});
|
||||
}
|
||||
|
||||
initHamburgerMenu();
|
||||
|
||||
// ==========================================
|
||||
// SOUND VISUALIZATION ANIMATION
|
||||
// ==========================================
|
||||
|
||||
Reference in New Issue
Block a user