1// <-- !è½®æå¾å¼å§ --> 2// document.addEventListener('DOMContentLoaded', function () { 3const slider = document.getElementById('slider') 4const slides = slider.querySelectorAll('.slide') 5 6let currentIndex = 0 7let slideCount = slides.length 8let autoPlayInterval 9let isAutoPlay = true 10 11// 忢尿å®å¹»ç¯ç 12function goToSlide(index) { 13 if (index < 0) { 14 currentIndex = slideCount - 1 15 } else if (index >= slideCount) { 16 currentIndex = 0 17 } else { 18 currentIndex = index 19 } 20 21 slider.style.transform = `translateX(-${currentIndex * 100}%)` 22} 23 24// ä¸ä¸å¼ å¹»ç¯ç 25function nextSlide() { 26 goToSlide(currentIndex + 1) 27} 28 29// ä¸ä¸å¼ å¹»ç¯ç 30function prevSlide() { 31 goToSlide(currentIndex - 1) 32} 33 34// èªå¨ææ¾åè½ 35function startAutoPlay() { 36 if (isAutoPlay) { 37 autoPlayInterval = setInterval(() => { 38 nextSlide() 39 }, 5000) 40 } 41} 42 43// åå§åè½®æå¾ 44function initSlider() { 45 startAutoPlay() 46 47 // é¼ æ æ¬åæ¶æåèªå¨ææ¾ 48 slider.parentElement.addEventListener('mouseenter', () => { 49 if (isAutoPlay) { 50 clearInterval(autoPlayInterval) 51 } 52 }) 53 54 // é¼ æ ç¦»å¼æ¶æ¢å¤èªå¨ææ¾ 55 slider.parentElement.addEventListener('mouseleave', () => { 56 if (isAutoPlay) { 57 startAutoPlay() 58 } 59 }) 60} 61// åå§åè½®æå¾ 62initSlider() 63// })
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.