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:
131
index.html
131
index.html
@@ -646,133 +646,12 @@
|
||||
</div> <div class="footer-bottom">
|
||||
<p>© 2025 Gyannetra. All rights reserved. | <a href="privacy-policy.html">Privacy Policy</a> | <a href="terms-of-service.html">Terms and Conditions</a></p>
|
||||
</div>
|
||||
</div> </footer> <script src="js/menu-dropdown.js" defer></script>
|
||||
<script src="js/main.js" defer></script>
|
||||
</div> </footer> <script src="js/main.js" defer></script>
|
||||
<script src="js/tech-marquee.js" defer></script>
|
||||
<script src="js/page-specific.js" defer></script>
|
||||
<script src="js/dynamic-content.js" defer></script>
|
||||
<script src="js/form-handler.js" defer></script>
|
||||
<script src="js/mobile-fix.js" defer></script>
|
||||
<script src="js/typewriter-effect.js" defer></script>
|
||||
<script src="js/menu-dropdown.js" defer></script>
|
||||
|
||||
<!-- Navbar scroll effect script -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const header = document.querySelector('.site-header');
|
||||
|
||||
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();
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Typewriter Effect Script -->
|
||||
<script>
|
||||
class TypewriterEffect {
|
||||
constructor(element, words, options = {}) {
|
||||
this.element = element;
|
||||
this.words = words;
|
||||
this.currentWordIndex = 0;
|
||||
this.currentCharIndex = 0;
|
||||
this.isDeleting = false;
|
||||
this.typeSpeed = options.typeSpeed || 120;
|
||||
this.deleteSpeed = options.deleteSpeed || 60;
|
||||
this.delayBetweenWords = options.delayBetweenWords || 3000;
|
||||
this.initialDelay = options.initialDelay || 2000;
|
||||
|
||||
setTimeout(() => this.type(), this.initialDelay);
|
||||
}
|
||||
|
||||
type() {
|
||||
const currentWord = this.words[this.currentWordIndex];
|
||||
|
||||
if (this.isDeleting) {
|
||||
this.element.textContent = currentWord.substring(0, this.currentCharIndex - 1);
|
||||
this.currentCharIndex--;
|
||||
|
||||
if (this.currentCharIndex === 0) {
|
||||
this.isDeleting = false;
|
||||
this.currentWordIndex = (this.currentWordIndex + 1) % this.words.length;
|
||||
setTimeout(() => this.type(), 500);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.element.textContent = currentWord.substring(0, this.currentCharIndex + 1);
|
||||
this.currentCharIndex++;
|
||||
|
||||
if (this.currentCharIndex === currentWord.length) {
|
||||
setTimeout(() => {
|
||||
this.isDeleting = true;
|
||||
this.type();
|
||||
}, this.delayBetweenWords);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const speed = this.isDeleting ? this.deleteSpeed : this.typeSpeed;
|
||||
setTimeout(() => this.type(), speed);
|
||||
}
|
||||
} // Initialize when page loads
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const typewriterElement = document.getElementById('typewriter');
|
||||
const words = [
|
||||
'AI Strategy & Roadmaps',
|
||||
'Custom LLM Solutions',
|
||||
'AI Automation & Workflows',
|
||||
'Data-Driven Business Intelligence',
|
||||
'Computer Vision Systems',
|
||||
'NLP & Chatbot Integrations',
|
||||
'AI for EdTech & Healthcare',
|
||||
'Predictive Analytics Tools'
|
||||
];
|
||||
new TypewriterEffect(typewriterElement, words);
|
||||
});
|
||||
|
||||
// EMERGENCY: Direct hamburger menu toggle function
|
||||
function toggleMobileMenu(event) {
|
||||
console.log('🍔 Direct hamburger toggle called!');
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const hamburger = document.querySelector('.hamburger-menu');
|
||||
const navLinks = document.querySelector('.nav-links');
|
||||
|
||||
if (hamburger && navLinks) {
|
||||
hamburger.classList.toggle('active');
|
||||
navLinks.classList.toggle('active');
|
||||
navLinks.classList.toggle('show');
|
||||
|
||||
const isOpen = navLinks.classList.contains('active') || navLinks.classList.contains('show');
|
||||
document.body.style.overflow = isOpen ? 'hidden' : '';
|
||||
|
||||
console.log('🍔 Menu toggled directly - open:', isOpen);
|
||||
console.log('🍔 Hamburger classes:', hamburger.className);
|
||||
console.log('🍔 Nav classes:', navLinks.className);
|
||||
} else {
|
||||
console.error('🍔 Hamburger or nav elements not found!');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user