【发布时间】:2013-04-08 10:49:02
【问题描述】:
关于CIRCULAR CONTENT CAROUSEL WITH JQUERY 的问题 通过鼓膜
我正在将这个实现到一个网络项目中,到目前为止它运行良好,但需要它停止循环/左右克隆并在到达最后一个孩子或第一个孩子时停止滚动。基本上是去除无限循环/循环效果。
我认为这是要改变的部分,但太糟糕了,我无法理解逻辑,
请帮忙!
抱歉英语不好,我来自马来西亚
//克隆右边/左边的元素,并根据dir和scroll追加/前置 如果(目录=== 1){ $wrapper.find('div.ca-item:lt(' + scroll + ')').each(function(i) { $(this).clone(true).css('left', (cache.totalItems - idxClicked + i) * cache.itemW * factor + 'px').appendTo($wrapper); }); } 别的 { var $first = $wrapper.children().eq(0);
$wrapper.find('div.ca-item:gt(' + ( cache.totalItems - 1 - scroll ) + ')').each(function(i) {
// insert before $first so they stay in the right order
$(this).clone(true).css( 'left', - ( scroll - i + idxClicked ) * cache.itemW * factor + 'px' ).insertBefore( $first );
});
}
// animate the left of each item
// the calculations are dependent on dir and on the cache.expanded value
$wrapper.find('div.ca-item').each(function(i) {
var $item = $(this);
$item.stop().animate({
left : ( dir === 1 ) ? '-=' + ( cache.itemW * factor * scroll ) + 'px' : '+=' + ( cache.itemW * factor * scroll ) + 'px'
}, opts.sliderSpeed, opts.sliderEasing, function() {
if( ( dir === 1 && $item.position().left < - idxClicked * cache.itemW * factor ) || ( dir === -1 && $item.position().left > ( ( cache.totalItems - 1 - idxClicked ) * cache.itemW * factor ) ) ) {
// remove the item that was cloned
$item.remove();
}
cache.isAnimating = false;
});
});
【问题讨论】:
-
在jsFiddle 中设置它,我会尝试一下
标签: jquery circular-content-carousel