我将 Cycle2 与轮播寻呼机一起使用,与此演示的方式相同:http://jquery.malsup.com/cycle2/demo/caro-pager.php http://jquery.malsup.com/cycle2/demo/caro-pager.php
目前演示中的活动幻灯片位于左侧,除非您在最后几张幻灯片上。我想要的是:
- 让活动幻灯片从幻灯片 1 的左侧开始
- 然后,当单击幻灯片 2 时,缩略图不会移动,但第二个缩略图显示为活动状态。
- 单击幻灯片 3 时,缩略图不会移动,但第三个缩略图(中间)变为活动状态。
- 单击幻灯片 4 时,所有缩略图都会向左移动一张,并且第四个缩略图(现在位于中间)处于活动状态。
- 与上述幻灯片 5、6、7 相同。
- 单击幻灯片 8 时,缩略图不会移动,但第八个缩略图变为活动状态(现在是右数第二个)
- 单击幻灯片 9 时,缩略图不会移动,但第九个缩略图变为活动状态(右侧最后一个缩略图)。
见图:
我已将演示复制到此处的 jsfiddle:http://jsfiddle.net/Qhp2g/1/ http://jsfiddle.net/Qhp2g/1/但真的很感激一些帮助,因为我不知道从哪里开始(!)我尝试过使用data-cycle-carousel-offset="40%"
on #cycle-2
因为该用户尝试了与我类似的问题Cycle2:主幻灯片下方的中心轮播活动幻灯片 https://stackoverflow.com/questions/20104385/cycle2-center-carousel-active-slide-below-main-slideshow这不起作用,因为您无法访问最后一张幻灯片,并且开头左侧有空间。
我想我可能需要更改插件轮播脚本 -http://malsup.github.io/jquery.cycle2.carousel.js http://malsup.github.io/jquery.cycle2.carousel.js- 满足我的需求,但真的不知道从哪里开始!非常感谢您的帮助。
您需要做的就是编辑 jquery.cycle2.carousel.js 文件,并更改转换函数。我对偏移量进行了硬编码,但如果您愿意,您可以根据您给出的百分比对其进行编码。
以下是主要变化:
var offset = 2; //Set the offset of your carousel, for 5 it will be 2.
//Use this offset to calculate the max and min slide locations.
var maxCurr = opts.slideCount - (opts.carouselVisible - offset);
var minCurr = opts.slideCount - (opts.carouselVisible + offset);
...
//Add the following conditions to account for the new minCurr
else if (hops > 0 && opts.nextSlide <= minCurr){
hops = 0;
}
else if (hops < 0 && opts.currSlide <= minCurr){
hops = 0;
}
else if (hops > 0 && opts.currSlide < minCurr && opts.nextSlide > minCurr){
hops = opts.nextSlide - minCurr;
}
else if (hops < 0 && opts.nextSlide < minCurr){
hops = opts.nextSlide - minCurr;
}
请参阅此处的工作小提琴:http://jsfiddle.net/m66tS/10/ http://jsfiddle.net/m66tS/10/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)