File size: 3,560 Bytes
910af9d 3d536db 910af9d 1c7f7ca 910af9d 1c7f7ca dfe7ff4 1c7f7ca dfe7ff4 1c7f7ca dfe7ff4 1c7f7ca e152d44 3d536db e152d44 3d536db | 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 |
document.addEventListener('DOMContentLoaded', function() {
// Mobile menu toggle
const header = document.querySelector('custom-header');
if (header) {
const mobileMenuBtn = header.shadowRoot.querySelector('.mobile-menu-btn');
const navLinks = header.shadowRoot.querySelector('.nav-links');
mobileMenuBtn.addEventListener('click', function() {
navLinks.classList.toggle('show');
});
}
// Smooth scroll for navigation links
document.querySelectorAll('custom-header').forEach(header => {
header.shadowRoot.querySelectorAll('.nav-link').forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth'
});
// Close mobile menu if open
const header = document.querySelector('custom-header');
const mobileMenuBtn = header.shadowRoot.querySelector('.mobile-menu-btn');
const navLinks = header.shadowRoot.querySelector('.nav-links');
navLinks.classList.remove('show');
mobileMenuBtn.classList.remove('active');
}
});
});
});
// Responsive adjustments for sections
function handleResize() {
const width = window.innerWidth;
// Adjust header padding based on screen size
const header = document.querySelector('custom-header').shadowRoot.querySelector('.header-content');
if (width < 768) {
header.style.padding = '1rem';
} else {
header.style.padding = '1rem 2rem';
}
// Adjust hero section text size
const heroText = document.querySelector('.container.mx-auto.text-center h1');
if (width < 640) {
heroText.style.fontSize = '2.2rem';
} else if (width < 1024) {
heroText.style.fontSize = '2.8rem';
} else {
heroText.style.fontSize = '3.5rem';
}
}
// Initialize on load
handleResize();
// Add event listener for resize
window.addEventListener('resize', handleResize);
// Add fade-in animation to sections
const sections = document.querySelectorAll('section');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
}
});
}, {
threshold: 0.1
});
sections.forEach(section => {
observer.observe(section);
});
// Make all buy buttons redirect to WhatsApp
const buyButtons = document.querySelectorAll('.animate-buy-btn');
buyButtons.forEach(button => {
button.addEventListener('click', function() {
window.open('https://wa.me/237693930778?text=Bonjour%20%F0%9F%91%8B%2C%20je%20veux%20acheter%20cette%20%C3%A9pulcheuse', '_blank');
});
});
// WhatsApp button hover effect
const whatsappBtn = document.querySelector('.fixed.bottom-6.right-6 a');
whatsappBtn.addEventListener('mouseenter', function() {
this.classList.add('animate-bounce');
});
whatsappBtn.addEventListener('mouseleave', function() {
this.classList.remove('animate-bounce');
});
}); |