Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
124 lines (106 loc) · 3.57 KB
/
Copy pathscript.js
File metadata and controls
124 lines (106 loc) · 3.57 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Mobile Menu Toggle
const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links');
burger.addEventListener('click', () => {
// Toggle Nav
nav.classList.toggle('active');
burger.classList.toggle('active');
});
// Close mobile menu when clicking outside
document.addEventListener('click', (e) => {
if (!nav.contains(e.target) && !burger.contains(e.target) && nav.classList.contains('active')) {
nav.classList.remove('active');
burger.classList.remove('active');
}
});
// Smooth Scrolling for Navigation Links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
// Close mobile menu if open
if (nav.classList.contains('active')) {
nav.classList.remove('active');
burger.classList.remove('active');
}
}
});
});
// Form Submission
const contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
// Here you would typically send the form data to a server
alert('Thank you for your message! We will get back to you soon.');
contactForm.reset();
});
}
// Intersection Observer for Animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe all sections and cards
document.querySelectorAll('section, .service-card, .pricing-card').forEach(element => {
observer.observe(element);
});
// Handle window resize
window.addEventListener('resize', () => {
if (window.innerWidth > 768) {
nav.classList.remove('active');
burger.classList.remove('active');
}
});
// Enhanced scroll animations with stagger effect
const observerOptionsEnhanced = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const enhancedObserver = new IntersectionObserver((entries) => {
entries.forEach((entry, index) => {
if (entry.isIntersecting) {
setTimeout(() => {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}, index * 100);
enhancedObserver.unobserve(entry.target);
}
});
}, observerOptionsEnhanced);
// Observe cards with enhanced animations
document.querySelectorAll('.service-card, .pricing-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
enhancedObserver.observe(card);
});
// Scroll to Top Button
const scrollToTopBtn = document.getElementById('scrollToTop');
window.addEventListener('scroll', () => {
if (window.pageYOffset > 300) {
scrollToTopBtn.classList.add('visible');
} else {
scrollToTopBtn.classList.remove('visible');
}
});
scrollToTopBtn.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});