pdf-rocket-reader / script.js
Majdnr111's picture
this app has to work on both pc and phones(android or ios)
c1b928a verified
Raw History Blame Contribute Delete
1.53 kB
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Mobile menu toggle
document.addEventListener('DOMContentLoaded', function() {
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const mobileNav = document.querySelector('.mobile-nav');
if(mobileMenuBtn && mobileNav) {
mobileMenuBtn.addEventListener('click', function() {
mobileNav.classList.toggle('show');
});
}
});
// Animation on scroll
const animateOnScroll = () => {
const elements = document.querySelectorAll('.feature-card');
elements.forEach(element => {
const elementPosition = element.getBoundingClientRect().top;
const screenPosition = window.innerHeight / 1.2;
if(elementPosition < screenPosition) {
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}
});
};
// Set initial state for animation
document.querySelectorAll('.feature-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'all 0.5s ease';
});
window.addEventListener('scroll', animateOnScroll);
window.addEventListener('load', animateOnScroll);
console.log("Modern Starter Template Loaded");