/* |-------------------------------------------------------------------------- | Smooth Auto Moving Tabs |-------------------------------------------------------------------------- */ document.addEventListener('DOMContentLoaded', function(){ const tabsNavs = document.querySelectorAll('.oman-tabs-nav'); tabsNavs.forEach(nav => { let autoScroll; let isPaused = false; function startAutoScroll() { stopAutoScroll(); autoScroll = setInterval(() => { if (!isPaused) { nav.scrollLeft += 1; /* |-------------------------------------------------------------------------- | Return To Start Smoothly |-------------------------------------------------------------------------- */ if ( nav.scrollLeft + nav.clientWidth >= nav.scrollWidth - 2 ) { nav.scrollTo({ left: 0, behavior: 'smooth' }); } } }, 45); // Speed } function stopAutoScroll() { clearInterval(autoScroll); } /* |-------------------------------------------------------------------------- | Pause On Hover / Touch |-------------------------------------------------------------------------- */ nav.addEventListener('mouseenter', () => { isPaused = true; }); nav.addEventListener('mouseleave', () => { isPaused = false; }); nav.addEventListener('touchstart', () => { isPaused = true; }); nav.addEventListener('touchend', () => { setTimeout(() => { isPaused = false; }, 3000); }); /* |-------------------------------------------------------------------------- | Manual Scroll Detection |-------------------------------------------------------------------------- */ nav.addEventListener('scroll', () => { isPaused = true; clearTimeout(nav.scrollTimeout); nav.scrollTimeout = setTimeout(() => { isPaused = false; }, 2500); }); startAutoScroll(); }); }); أقسام موقع عروض عمان - الصفحة 63 من 284 - عروض عمان
تخطى إلى المحتوى