-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
144 lines (125 loc) · 4.56 KB
/
script.js
File metadata and controls
144 lines (125 loc) · 4.56 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Mobile Menu Toggle
const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
const navLinks = document.querySelector('.nav-links');
const navActions = document.querySelector('.nav-actions');
if (mobileMenuToggle) {
mobileMenuToggle.addEventListener('click', () => {
navLinks.classList.toggle('active');
navActions.classList.toggle('active');
mobileMenuToggle.classList.toggle('active');
});
}
// Smooth Scrolling
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'
});
}
});
});
// Pricing Toggle
const pricingToggle = document.getElementById('pricing-toggle');
const priceAmounts = document.querySelectorAll('.price-amount');
if (pricingToggle) {
pricingToggle.addEventListener('change', function() {
const isAnnual = this.checked;
priceAmounts.forEach(amount => {
const currentText = amount.textContent;
if (currentText.includes('$')) {
const monthlyPrice = parseInt(currentText.replace('$', ''));
if (isAnnual) {
const annualPrice = Math.round(monthlyPrice * 12 * 0.8);
amount.textContent = `$${annualPrice}`;
} else {
amount.textContent = `$${monthlyPrice}`;
}
}
});
});
}
// Navbar Dynamic Background Based on Section
const navbar = document.querySelector('.navbar');
const sections = document.querySelectorAll('section[data-section-theme], footer[data-section-theme]');
function updateNavbarTheme() {
const scrollPosition = window.pageYOffset + navbar.offsetHeight + 100;
let currentTheme = 'light'; // Default to light
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionBottom = sectionTop + section.offsetHeight;
const theme = section.getAttribute('data-section-theme');
if (scrollPosition >= sectionTop && scrollPosition < sectionBottom) {
currentTheme = theme;
}
});
// Update navbar classes
if (currentTheme === 'dark') {
navbar.classList.add('dark-theme');
} else {
navbar.classList.remove('dark-theme');
}
// Update shadow on scroll
if (window.pageYOffset > 100) {
navbar.style.boxShadow = currentTheme === 'dark'
? '0 4px 6px -1px rgba(0, 0, 0, 0.3)'
: '0 4px 6px -1px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.boxShadow = 'none';
}
}
// Update on scroll
window.addEventListener('scroll', updateNavbarTheme);
// Update on load
window.addEventListener('load', updateNavbarTheme);
// Update on resize
window.addEventListener('resize', updateNavbarTheme);
// 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.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe feature cards
document.querySelectorAll('.feature-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
// Observe testimonial cards
document.querySelectorAll('.testimonial-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
// Observe pricing cards
document.querySelectorAll('.pricing-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(card);
});
// Parallax Effect for Hero
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const heroVisual = document.querySelector('.hero-visual');
if (heroVisual && scrolled < window.innerHeight) {
heroVisual.style.transform = `translateY(${scrolled * 0.3}px)`;
}
});
// Add loading animation
window.addEventListener('load', () => {
document.body.classList.add('loaded');
});