-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
61 lines (53 loc) · 1.88 KB
/
script.js
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
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Header scroll effect
const header = document.querySelector('header');
window.addEventListener('scroll', () => {
if (window.scrollY > 100) {
header.style.backgroundColor = 'rgba(255, 255, 255, 0.95)';
} else {
header.style.backgroundColor = '#ffffff';
}
});
// Form submission
const contactForm = document.querySelector('.contact-form form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Get form values
const name = this.querySelector('input[type="text"]').value;
const email = this.querySelector('input[type="email"]').value;
const message = this.querySelector('textarea').value;
// Here you would typically send this data to a server
console.log('Form submitted:', { name, email, message });
// Show success message
alert('Thank you for your message! We will get back to you soon.');
this.reset();
});
}
// Add animation to cards on scroll
const cards = document.querySelectorAll('.card');
const observerOptions = {
threshold: 0.2
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
cards.forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
observer.observe(card);
});