Fix JavaScript conflicts and optimize typewriter effect
- Removed 15+ redundant JavaScript files causing conflicts - Optimized typewriter-effect.js with smoother animations - Consolidated hamburger menu implementations - Cleaned up duplicate inline scripts across all pages - Enhanced main.js with consolidated scroll effects - Improved page loading performance by eliminating conflicts - Fixed lagging/vibrating typewriter effect in hero section - Updated all HTML pages to use only 4 core JavaScript files
This commit is contained in:
34
js/main.js
34
js/main.js
@@ -8,6 +8,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
initParallaxEffects();
|
||||
initSectionTransitions();
|
||||
initCursorEffects();
|
||||
initScrollEffects();
|
||||
|
||||
// Remove page loader when everything is ready
|
||||
setTimeout(() => {
|
||||
@@ -16,6 +17,39 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}, 300);
|
||||
});
|
||||
|
||||
// Initialize scroll effects for navbar
|
||||
function initScrollEffects() {
|
||||
const header = document.querySelector('.site-header');
|
||||
|
||||
if (!header) return;
|
||||
|
||||
function handleScroll() {
|
||||
const currentScrollY = window.scrollY;
|
||||
|
||||
if (currentScrollY > 30) {
|
||||
header.classList.add('scrolled');
|
||||
} else {
|
||||
header.classList.remove('scrolled');
|
||||
}
|
||||
}
|
||||
|
||||
// Throttle scroll events for better performance
|
||||
let ticking = false;
|
||||
function onScroll() {
|
||||
if (!ticking) {
|
||||
requestAnimationFrame(function() {
|
||||
handleScroll();
|
||||
ticking = false;
|
||||
});
|
||||
ticking = true;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
// Initial check
|
||||
handleScroll();
|
||||
}
|
||||
|
||||
// Animate elements when they enter viewport
|
||||
function initScrollAnimations() {
|
||||
// Exclude hero content from scroll animations to prevent layout shifts
|
||||
|
||||
Reference in New Issue
Block a user