代码拉取完成,页面将自动刷新
let nextDom = document.getElementById("next");
let prevDom = document.getElementById("prev");
let carouselDom = document.querySelector(".carousel");
let listItemDom = document.querySelector(".carousel .list");
let thumbnailDom = document.querySelector(".carousel .thumbnail");
nextDom.onclick = function () {
showSlide("next");
};
prevDom.onclick = function () {
showSlide("prev");
};
let timeRunning = 300;
let timeAutoNext = 5000;
let runTimeOut;
let runAutoRun = setTimeout(() => {
prevDom.click();
}, timeAutoNext);
function showSlide(type) {
let itemSlider = document.querySelectorAll(".carousel .list .item");
let itemThumbnail = document.querySelectorAll(".carousel .thumbnail .item");
if (type === "next") {
listItemDom.appendChild(itemSlider[0]);
thumbnailDom.appendChild(itemThumbnail[0]);
carouselDom.classList.add("next");
} else {
let positionLastItem = itemSlider.length - 1;
listItemDom.prepend(itemSlider[positionLastItem]);
thumbnailDom.prepend(itemThumbnail[positionLastItem]);
carouselDom.classList.add("prev");
}
clearTimeout(runTimeOut);
runTimeOut = setTimeout(() => {
carouselDom.classList.remove("next");
carouselDom.classList.remove("prev");
}, timeRunning);
clearTimeout(runAutoRun);
runAutoRun = setTimeout(() => {
prevDom.click();
}, timeAutoNext);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。