40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
document.addEventListener('DOMContentLoaded', function () {
|
|
// Navbar shrink on scroll
|
|
const navbar = document.querySelector('.navbar');
|
|
if (navbar) {
|
|
window.addEventListener('scroll', () => {
|
|
if (window.scrollY > 50) {
|
|
navbar.classList.add('scrolled');
|
|
} else {
|
|
navbar.classList.remove('scrolled');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Smooth scroll for anchor 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'
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// Pricing toggle
|
|
const priceToggle = document.getElementById('priceToggle');
|
|
if (priceToggle) {
|
|
priceToggle.addEventListener('change', function() {
|
|
const isYearly = this.checked;
|
|
document.querySelectorAll('[data-monthly]').forEach(priceEl => {
|
|
const monthly = priceEl.getAttribute('data-monthly');
|
|
const yearly = priceEl.getAttribute('data-yearly');
|
|
priceEl.textContent = isYearly ? yearly : monthly;
|
|
});
|
|
});
|
|
}
|
|
});
|