|
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
|
|
anchor.addEventListener('click', function (e) { |
|
|
e.preventDefault(); |
|
|
document.querySelector(this.getAttribute('href')).scrollIntoView({ |
|
|
behavior: 'smooth' |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
const lazyImages = [].slice.call(document.querySelectorAll('img.lazy')); |
|
|
|
|
|
if ('IntersectionObserver' in window) { |
|
|
let lazyImageObserver = new IntersectionObserver(function(entries, observer) { |
|
|
entries.forEach(function(entry) { |
|
|
if (entry.isIntersecting) { |
|
|
let lazyImage = entry.target; |
|
|
lazyImage.src = lazyImage.dataset.src; |
|
|
lazyImage.classList.remove('lazy'); |
|
|
lazyImageObserver.unobserve(lazyImage); |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
lazyImages.forEach(function(lazyImage) { |
|
|
lazyImageObserver.observe(lazyImage); |
|
|
}); |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
function toggleMobileMenu() { |
|
|
const menu = document.getElementById('mobile-menu'); |
|
|
const button = document.getElementById('menu-button'); |
|
|
const isExpanded = button.getAttribute('aria-expanded') === 'true'; |
|
|
|
|
|
button.setAttribute('aria-expanded', !isExpanded); |
|
|
menu.classList.toggle('hidden'); |
|
|
menu.classList.toggle('block'); |
|
|
|
|
|
|
|
|
const icon = button.querySelector('svg'); |
|
|
if (isExpanded) { |
|
|
icon.setAttribute('data-feather', 'menu'); |
|
|
} else { |
|
|
icon.setAttribute('data-feather', 'x'); |
|
|
} |
|
|
feather.replace(); |
|
|
} |
|
|
|
|
|
|
|
|
const animateOnScroll = new IntersectionObserver((entries) => { |
|
|
entries.forEach(entry => { |
|
|
if (entry.isIntersecting) { |
|
|
entry.target.classList.add('animate-fade-in'); |
|
|
animateOnScroll.unobserve(entry.target); |
|
|
} |
|
|
}); |
|
|
}, { |
|
|
threshold: 0.1 |
|
|
}); |
|
|
|
|
|
document.querySelectorAll('.service-card, .project-card, .blog-card').forEach(card => { |
|
|
animateOnScroll.observe(card); |
|
|
}); |
|
|
|
|
|
|
|
|
function switchLanguage(lang) { |
|
|
|
|
|
console.log(`Switching to ${lang} version`); |
|
|
|
|
|
alert(`This would switch to the ${lang === 'fr' ? 'French' : 'English'} version of the site`); |
|
|
} |