我正在使用cycle插件来滑动内容。当我在滑动时多次点击“上一张”或“下一张”按钮时,它只是在动画完成之前跳到另一张幻灯片。
我试图在滑动时禁用导航按钮,但它不起作用。
js:
$('#slider ul').cycle({
timeout: 0,
fx: 'scrollHorz',
prev: '#prev',
next: '#next',
after: onAfter,
onPrevNextEvent: function(isNext, zeroBasedSlideIndex, slideElement){
$('#nav a').attr('disabled','disabled');
if (isNext == true || isNext == false) {
console.log('bool')
}
}
});
function onAfter(curr, next, opts) {
var index = opts.currSlide;
$('#prev')[index == 0 ? 'hide' : 'show']();
$('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}
我使用回调onPrevNextEvent
来检查isNext
是否为boolean
。在这个条件之前,我做了一个在导航链接上添加属性的测试,它添加了属性,但不会阻止prev/next函数。如何禁用/启用它?如果能帮上忙,我们将不胜感激
发布于 2014-12-24 04:39:41
你不能改变插件代码中的点击行为吗?也许在cycle插件初始化后不久,你可以抛出一个额外的事件来阻止传播。这样,如果isNext
为真,它将停止单击事件触发插件的操作。
类似于:
//just finished setting up the plugin
$("#prev,#next").on("click", function(e) {
if(isNext) e.stopPropagation();
});
https://stackoverflow.com/questions/27626936
复制相似问题