我在這Shopify主題中有一個旋轉木馬,我試圖編輯它,使其自動滾動到下一張幻燈片,每5秒(而不是點擊進入下一張幻燈片)。如何使Shopify主題中的傳送帶自動滾動?
這裏是我使用的傳送帶什麼:
//Carousel interaction
(function() {
if (document.getElementById('carousel-nav')) {
var slides = document.getElementById('carousel-images'),
slidesItems = slides.getElementsByTagName('li'),
nav = document.getElementById('carousel-nav'),
navItems = nav.getElementsByTagName('li'),
current = 0;
function showSlide(i) {
if (i != current && slidesItems[i]) {
slide = slidesItems[i];
slide.className += ' show';
setTimeout (function() {
slide.className = slide.className.replace('show', 'appear');
}, 1);
setTimeout(function() {
slidesItems[current].className = slidesItems[current].className.replace('current', '');
slide.className = slide.className.replace('appear', 'current');
current = i;
}, 300);
navItems[i+1].className += ' current';
navItems[current+1].className = navItems[current+1].className.replace('current', '');
if (i == 0) {
if (navItems[0].className.indexOf('disabled') == -1) {
navItems[0].className += ' disabled';
}
} else {
navItems[0].className = navItems[0].className.replace(' disabled', '');
}
var l = navItems.length - 1;
if (i == slidesItems.length - 1) {
if (navItems[l].className.indexOf('disabled') == -1) {
navItems[l].className += ' disabled';
}
} else {
navItems[l].className = navItems[l].className.replace(' disabled', '');
}
}
}
nav.onclick = function(e) {
e = e || window.event; e = e.target || e.srcElement;
e = getParentByTagName(e, 'A');
if (e) {
var action = e.getAttribute('data-action');
if (action == 'prev') {
showSlide(current - 1);
} else if (action == 'next') {
showSlide(current + 1);
} else {
showSlide(parseInt(action));
}
}
return false;
}
}
})();
任何想法?我有點難住。
謝謝!
你使用了哪個傳送帶插件,我們可以看到網頁在線嗎? –
這是Clearflex主題:http://themes.shopify.com/themes/clearflex/styles/lighthouse –
這是一個鏈接到網站:http://www.jackedpack.com/ –