問題出在下面的代碼部分:
if(typeof click != "undefined")
config.auto = false;
您使用後的任何它的導航,有效地停止傳送帶。 爲了解決這個問題,你需要:
編輯以添加動畫超時復位:
添加將存儲超時變量,如果超時被激活:
var myTimer, timerActive = false;
var li = ul.children('li');
右後
替換:
if(typeof click != "undefined")
config.auto = false;
if(config.auto!=false)
setTimeout(function() {
slide('next');
}, config.auto);
有:
if(typeof click != "undefined"){
if(config.auto!=false){
if (timerActive) clearTimeout(myTimer);
myTimer = setTimeout(function() {
slide('next');
}, config.auto * 2);
}
timerActive = true;
}
else{
if(config.auto!=false){
if (timerActive) clearTimeout(myTimer);
myTimer = setTimeout(function() {
slide('next');
}, config.auto);
timerActive = true;
}
}
,並在旋轉木馬代碼的末尾替換:
if(config.auto!=false)
setTimeout(function() {
slide('next');
}, config.auto);
有:
if(config.auto!=false){
if (timerActive) clearTimeout(myTimer);
myTimer = setTimeout(function() {
slide('next');
}, config.auto);
timerActive = true;
}
----結束編輯----
請注意,我還沒有真正測試過任何 - 有可能是拼寫錯誤等 如果它不起作用,你總是可以嘗試爲jQuery旋轉木馬我寫https://github.com/c2h5oh/jQuery-Cycle-Uber-Lite
謝謝,它看起來像這樣開始達到肯定的結果,但它有點奇怪。當碰到上一張或下一張幻燈片時,只出現一個片刻,然後快速返回到下一張幻燈片,然後其他幻燈片像第一張幻燈片一樣快速 – David
這是因爲更改沒有重置超時這已經設置 - 它必須保存到變量('var x = setTimeout()'),所以可以使用'clearTimeout(x)'。 – c2h5oh
我是一個新手,我無法使用clearTimeout(x)爲我工作......請告訴我腳本完成的內容是什麼樣子的? – David