Anr*_*rgh 7 jquery jquery-plugins jquery-effects jquery-cycle
我目前正在使用jQuery.Cycle循环遍历一些子<div>
标签.但是,我想要默认循环fx fade
,当我单击next
或prev
选择器时,我希望循环fx暂时更改为scrollRight
或scrollLeft
取决于单击的选择器.
这可能吗?
jQuery代码,如有必要:
$('#banner_content').cycle({
fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
timeout: 6500,
speed: 2000,
next: $("#right_arrow a"),
prev: $("#left_arrow a"),
});
Run Code Online (Sandbox Code Playgroud)
Anr*_*rgh 11
好的,我在jQuery论坛上添加了我的问题,创建者回答了以下答案.
这是我为此开发的代码:
var slideIndex = 0;
var nextIndex = 0;
var prevIndex = 0;
$('#banner_content').cycle({
fx: 'fade',//fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
timeout: 8000,
speed: 1000,
easingIn:20,
easingOut:40,
after: function(currSlideElement, nextSlideElement, options) {
slideIndex = options.currSlide;
nextIndex = slideIndex + 1;
prevIndex = slideIndex -1;
if (slideIndex == options.slideCount-1) {
nextIndex = 0;
}
if (slideIndex == 0) {
prevIndex = options.slideCount-1;
}
}
});
$("div.left_arrow a").click(function () {
$('#banner_content').cycle(nextIndex, "scrollRight");
});
$("div.right_arrow a").click(function () {
$('#banner_content').cycle(prevIndex, "scrollLeft");
});
Run Code Online (Sandbox Code Playgroud)