// Ultra responsive mobile and desktop scrolling function init() { console.log('Applying ultra responsive scroll enhancements...'); // Create mobile-optimized scroll CSS const ultraScrollCSS = document.createElement('style'); ultraScrollCSS.id = 'ultra-scroll-enhance'; ultraScrollCSS.innerHTML = ` /* ULTRA RESPONSIVE SCROLLING FOR ALL DEVICES */ html { scroll-behavior: auto !important; -webkit-overflow-scrolling: touch !important; overflow-scrolling: touch !important; overflow-x: hidden !important; overflow-y: auto !important; height: 100% !important; touch-action: pan-y !important; } body { scroll-behavior: auto !important; -webkit-overflow-scrolling: touch !important; overflow-scrolling: touch !important; overflow-x: hidden !important; overflow-y: auto !important; min-height: 100vh !important; position: static !important; touch-action: pan-y !important; } /* PRESERVE BEAUTIFUL HOVER EFFECTS */ .hover\\:scale-105:hover { transform: scale(1.05) !important; transition: transform 0.3s ease !important; } .hover\\:scale-110:hover { transform: scale(1.1) !important; transition: transform 0.3s ease !important; } .hover\\:z-30:hover { z-index: 30 !important; } .hover\\:translate-y-0:hover { transform: translateY(0) !important; transition: transform 0.3s ease !important; } .hover\\:-translate-y-2:hover { transform: translateY(-0.5rem) !important; transition: transform 0.3s ease !important; } /* MOBILE ULTRA LOOSE SCROLLING */ @media (max-width: 768px) { html, body { -webkit-overflow-scrolling: touch !important; scroll-behavior: auto !important; position: static !important; height: auto !important; overflow-y: auto !important; overflow-x: hidden !important; touch-action: pan-y !important; overscroll-behavior: auto !important; -webkit-overscroll-behavior: auto !important; } /* Remove all scroll resistance */ * { -webkit-overflow-scrolling: touch !important; scroll-snap-type: none !important; scroll-snap-align: none !important; overscroll-behavior: auto !important; -webkit-overscroll-behavior: auto !important; } /* Ultra smooth container scrolling */ .container, section, div { contain: none !important; will-change: auto !important; -webkit-overflow-scrolling: touch !important; } } `; // Remove existing styles const existingFix = document.getElementById('ultra-scroll-enhance'); if (existingFix) existingFix.remove(); // Add new styles with highest priority document.head.insertBefore(ultraScrollCSS, document.head.firstChild); // Detect device type const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent) || window.innerWidth <= 768; if (isMobile) { // ULTRA LOOSE MOBILE SCROLLING document.documentElement.style.cssText += ` scroll-behavior: auto !important; -webkit-overflow-scrolling: touch !important; touch-action: pan-y !important; overscroll-behavior: auto !important; -webkit-overscroll-behavior: auto !important; height: 100% !important; overflow-x: hidden !important; overflow-y: auto !important; `; document.body.style.cssText += ` scroll-behavior: auto !important; -webkit-overflow-scrolling: touch !important; touch-action: pan-y !important; overscroll-behavior: auto !important; -webkit-overscroll-behavior: auto !important; position: static !important; height: auto !important; min-height: 100vh !important; overflow-x: hidden !important; overflow-y: auto !important; `; // Mobile touch scroll with 4x sensitivity and momentum let lastTouchY = 0; let touchVelocity = 0; let touchStartTime = 0; function handleMobileTouchStart(e) { lastTouchY = e.touches[0].clientY; touchVelocity = 0; touchStartTime = Date.now(); } function handleMobileTouchMove(e) { const currentTouchY = e.touches[0].clientY; const deltaY = lastTouchY - currentTouchY; const currentTime = Date.now(); const timeDelta = currentTime - touchStartTime; touchVelocity = deltaY / (timeDelta || 1); lastTouchY = currentTouchY; // ULTRA sensitive mobile scrolling - 4x sensitivity if (Math.abs(deltaY) > 1) { const scrollAmount = deltaY * 4; // 4x more sensitive window.scrollBy(0, scrollAmount); } } function handleMobileTouchEnd() { // Enhanced momentum scrolling if (Math.abs(touchVelocity) > 0.5) { const momentum = touchVelocity * 800; // Massive momentum multiplier window.scrollBy({ top: momentum, behavior: 'smooth' }); } } // Add ultra-responsive mobile touch listeners document.addEventListener('touchstart', handleMobileTouchStart, { passive: true }); document.addEventListener('touchmove', handleMobileTouchMove, { passive: true }); document.addEventListener('touchend', handleMobileTouchEnd, { passive: true }); // Optimize mobile viewport for ultra smooth scrolling let viewport = document.querySelector('meta[name="viewport"]'); if (!viewport) { viewport = document.createElement('meta'); viewport.name = 'viewport'; document.head.appendChild(viewport); } viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes, viewport-fit=cover'); console.log('🚀 ULTRA LOOSE MOBILE SCROLLING ACTIVATED - 4x sensitivity with massive momentum!'); } else { // ENHANCED DESKTOP SCROLLING let isWheelScrolling = false; function handleDesktopWheel(e) { if (isWheelScrolling) return; e.preventDefault(); isWheelScrolling = true; // Enhanced desktop scroll - 3x sensitivity const scrollAmount = e.deltaY * 3; const currentScroll = window.pageYOffset; const targetScroll = Math.max(0, currentScroll + scrollAmount); window.scrollTo({ top: targetScroll, behavior: 'smooth' }); setTimeout(() => { isWheelScrolling = false; }, 20); } document.addEventListener('wheel', handleDesktopWheel, { passive: false }); console.log('🖥️ Enhanced desktop scrolling activated - 3x sensitivity'); } console.log('✅ Ultra responsive scroll system initialized!'); } function teardown() { const scrollFix = document.getElementById('ultra-scroll-enhance'); if (scrollFix) { scrollFix.remove(); } console.log('Scroll enhancements removed'); } export { init, teardown };