-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (46 loc) · 1.85 KB
/
Copy pathscript.js
File metadata and controls
53 lines (46 loc) · 1.85 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
document.addEventListener('DOMContentLoaded', () => {
// --- Gestion du formulaire (Simulation) ---
const form = document.getElementById('booking-form');
if (form) {
form.addEventListener('submit', (e) => {
e.preventDefault();
const btn = form.querySelector('.btn-submit');
const originalText = btn.textContent;
btn.textContent = "Envoi en cours...";
btn.style.opacity = "0.7";
// Simule un envoi réseau
setTimeout(() => {
alert("Merci ! Votre demande a été enregistrée. Nous vous contacterons rapidement.");
form.reset();
btn.textContent = originalText;
btn.style.opacity = "1";
}, 1000);
});
}
// --- Animation au scroll (Intersection Observer) ---
// Cette partie détecte quand un élément ".fade-in" entre dans l'écran
const observerOptions = {
threshold: 0.1, // Déclenche quand 10% de l'élément est visible
rootMargin: "0px 0px -50px 0px"
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target); // Ne joue l'animation qu'une fois
}
});
}, observerOptions);
document.querySelectorAll('.fade-in').forEach(el => {
observer.observe(el);
});
// --- Smooth Scroll pour les ancres ---
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
});