我有一个像动画一样的图像滑块,不同之处在于一张幻灯片中有几个元素,在我的例子中,有 4 张图片来自场景的左侧或右侧。
问题是如何使触发动画功能的链接被禁用,直到动画100%完成,然后再次启用。
这是我的代码...
$(document).ready(function() {
//
$('.package_box_menu li').children().click(function(){
$(this).showProducts($(this).attr("id"))
});
jQuery.fn.showProducts = function (clickedSeason) {
var nextToShowSide = $('.'+[clickedSeason]+'_img1').attr("rel");
var active = $('img[ rel |= active]').attr('season');
if (nextToShowSide == 'right') {var whereTo = '-1000px'; var currentToHideSide ="left" };
if (nextToShowSide == 'left') {var whereTo = '3000px'; var currentToHideSide ="right" };
show();
hide(active, whereTo, currentToHideSide);
function show(){
var allToShow = ($('img[ season |= '+[clickedSeason]+']').get()).length;
for (var i = 1; i<= allToShow ; i++){
var delay = $('.'+[clickedSeason]+'_img'+[i]).attr('delay');
var position = $('.'+[clickedSeason]+'_img'+[i]).attr('left');
$('.'+[clickedSeason]+'_img'+[i]).stop().delay(delay).animate({'margin-left': position }, 1000, 'easeOutExpo').attr('rel','active');
}
};
function hide(active, whereTo, currentToHideSide){
var all = ($('img[ rel |= active]').get()).length;
for (var i = 1; i<= all ; i++){
if ($('.'+[active]+'_img'+[i]).attr('rel') == 'active') {
$('.'+[active]+'_img'+[i]).stop().delay([i]+'00').animate({'margin-left': whereTo }, 1000, 'easeInExpo').attr('rel', currentToHideSide );
}
}
};
};
jQuery().showProducts('spring');
});