我有一个旋转木马和一组拇指。轮播设置为在页面加载时自动滚动。但是,当单击缩略图时,我想暂停轮播。
我试图在缩略图的点击事件上实现这一点,然后使用触发器滑动到点击的拇指,然后暂停。
问题是,使用以下代码,它会暂停轮播,但不会将轮播图像更改为单击的图像。如果我删除暂停触发器,轮播将变为单击的拇指。
<script>
$(function(){
/* Attached an unique class name to each thumbnail image */
$('#thumbs .thumb a').each(function(i) {
$(this).addClass( 'itm'+i );
/* add onclick event to thumbnail to make the main
carousel scroll to the right slide*/
$(this).click(function() {
$('#project-carousel').trigger( 'slideTo', [i, 0, true] );
$('#project-carousel').trigger('pause', true);
return false;
});
});
/* Highlight the first item on first load */
$('#thumbs a.itm0').addClass( 'selected' );
//slideshow
projectCarousel = $("#project-carousel").carouFredSel({
responsive:true,
circular:true,
infinite:true,
width:983,
height:534,
scroll:{
fx:'crossfade',
duration:1000,
onBefore: function() {
/* Everytime the main slideshow changes, it check to
make sure thumbnail and page are displayed correctly */
/* Get the current position */
var pos = $(this).triggerHandler( 'currentPosition' );
/* Reset and select the current thumbnail item */
$('#thumbs a').removeClass( 'selected' );
$('#thumbs a.itm'+pos).addClass( 'selected' );
/* Move the thumbnail to the right page */
//var page = Math.floor( pos / 8 );
//$('#thumbs').trigger( 'slideToPage', page );
}
},
auto: {
play:true,
},
items:{
height:winHeight,
visible:1,
width:1000
},
prev:$("#left"),
next:$("#right"),
});
/* Carousel for the thumbnails */
$('#thumbs').carouFredSel({
width:680,
height:50,
direction: 'left',
circular: false,
items: 9,
infinite: false,
align: false,
auto: false,
prev: '#prev',
next: '#next'
});
});
</script>
如何让轮播进入点击的缩略图,然后暂停?