我是新手而且坚持这一点,非常感谢你的帮助。
我希望滑块能够轻弹4张图像,然后随机停在一张图像上,然后按住几秒钟,然后再次轻弹4并随机停在另一张图片上并继续这样做。这会变得非常复杂吗?
提前致谢:)
这是在jsfiddle.net/zFgz7/3/中滚动的链接,该功能仅跳过两张图片并在第3张停止,如何让它跳过4或5张图片并在下一张图片上停留2秒?
jQuery(function($) {
$(document).ready(function() {
$('.slides').cycle({
fx: 'none',
speed: 80,
timeout: 80,
timeoutFn: calculateTimeout
}).cycle("pause");
}); // END doc ready
}); // END function
function calculateTimeout(currElement, nextElement, opts, isForward) {
// here we set even number slides to have a 2 second timeout;
// by returning false for odd number slides we let those slides
// inherit the default timeout value (4 sec)
var index = opts.currSlide;
return index % 2 ? 2000 : false;
}
答案 0 :(得分:3)
这样做,
var myCounter = 0;
$('.slides').cycle({
fx: 'none',
speed: 80,
timeout: 80,
timeoutFn: calculateTimeout
}).cycle("pause");
function calculateTimeout( currElement, nextElement, opts, isForward) {
// here we set even number slides to have a 2 second timeout;
// by returning false for odd number slides we let those slides
// inherit the default timeout value (4 sec)
myCounter++;
return myCounter % 5 ? 50 : 2000;
}
(确保myCounter
变量和calculateTimeout
方法在同一范围内,以便该方法可以访问变量)