-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
81 lines (69 loc) · 2.89 KB
/
script.js
File metadata and controls
81 lines (69 loc) · 2.89 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
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
// Language switching functionality
let currentLang = 'en';
function switchLanguage(lang) {
currentLang = lang;
// Update language switch buttons
document.querySelectorAll('.lang-option').forEach(option => {
option.classList.remove('active');
if (option.dataset.lang === lang) {
option.classList.add('active');
}
});
// Update all translatable elements
document.querySelectorAll('[data-en][data-fr]').forEach(element => {
if (lang === 'en') {
element.textContent = element.dataset.en;
} else {
element.textContent = element.dataset.fr;
}
});
}
// Language switch event listeners
document.querySelectorAll('.lang-option').forEach(option => {
option.addEventListener('click', () => {
switchLanguage(option.dataset.lang);
});
});
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Scroll animations
function animateOnScroll() {
const elements = document.querySelectorAll('.fade-in');
elements.forEach(element => {
const elementTop = element.getBoundingClientRect().top;
const elementVisible = 150;
if (elementTop < window.innerHeight - elementVisible) {
element.classList.add('visible');
}
});
}
window.addEventListener('scroll', animateOnScroll);
animateOnScroll(); // Run once on load
// Form submission
document.querySelector('form').addEventListener('submit', function(e) {
e.preventDefault();
const message = currentLang === 'en'
? 'Thank you for your message! We will get back to you soon.'
: 'Merci pour votre message ! Nous vous répondrons bientôt.';
alert(message);
this.reset();
});
// Parallax effect for hero
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const hero = document.querySelector('.hero');
if (hero) {
hero.style.transform = `translateY(${scrolled * 0.5}px)`;
}
});