| // Advanced UI Interactions | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Animate elements on scroll | |
| const animateOnScroll = () => { | |
| const elements = document.querySelectorAll('.scroll-animate'); | |
| elements.forEach(el => { | |
| const rect = el.getBoundingClientRect(); | |
| const isVisible = (rect.top <= window.innerHeight * 0.8); | |
| if (isVisible) { | |
| el.classList.add('animate-fadeInUp'); | |
| } | |
| }); | |
| }; | |
| window.addEventListener('scroll', animateOnScroll); | |
| animateOnScroll(); | |
| // Initialize smooth scroll for anchor links | |
| document.querySelectorAll('a[href^="#"]').forEach(anchor => { | |
| anchor.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| document.querySelector(this.getAttribute('href')).scrollIntoView({ | |
| behavior: 'smooth' | |
| }); | |
| }); | |
| }); | |
| // Initialize tooltips | |
| const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); | |
| tooltipTriggerList.map(function (tooltipTriggerEl) { | |
| return new bootstrap.Tooltip(tooltipTriggerEl); | |
| }); | |
| console.log('SparkleMatic Auto Elegance loaded'); | |
| }); | |
| // Parallax effect | |
| window.addEventListener('scroll', function() { | |
| const scrollPosition = window.pageYOffset; | |
| const parallaxElements = document.querySelectorAll('.parallax'); | |
| parallaxElements.forEach(element => { | |
| const speed = parseFloat(element.dataset.speed) || 0.5; | |
| const yPos = -(scrollPosition * speed); | |
| element.style.transform = `translate3d(0, ${yPos}px, 0)`; | |
| }); | |
| }); | |