[英]How to make a carouFredSel autoplay and sync?
I've got the carousel (I think it made of bootstrap) which I derived from the template from themeforest. 我有旋转木马(我认为它是由引导程序制成的),它是从themeforest的模板派生而来的。 It works well until I want to make it autoplay.
在我想使其自动播放之前,它运作良好。 I tried set
interval:1000
but it still not work. 我尝试设置
interval:1000
但仍然无法正常工作。 Here is the script: 这是脚本:
function InitPropertyCarousel() {
if ($('.carousel.property .content li img').length !== 0) {
$('.carousel.property .content li img').on({
click: function(e) {
var src = $(this).attr('src');
var img = $(this).closest('.carousel.property').find('.preview img');
img.attr('src', src);
$('.carousel.property .content li').each(function() {
$(this).removeClass('active');
});
$(this).closest('li').addClass('active');
}
});
}
}
This is the example link : http://preview.byaviators.com/template/realia/detail.html . 这是示例链接: http : //preview.byaviators.com/template/realia/detail.html 。 (I tried put this code on jsfiddle but it's not working.)
(我尝试将这段代码放在jsfiddle上,但无法正常工作。)
I think you are using this carousel carouFredSell . 我认为您正在使用此轮播carouFredSell 。 And the real initialize code is this:
真正的初始化代码是这样的:
function InitCarousel() {
if ($('#main .carousel .content ul').length !== 0) {
$('#main .carousel .content ul').carouFredSel({
scroll: {
items: 1
},
auto: false,
next: {
button: '#main .carousel-next',
key: 'right'
},
prev: {
button: '#main .carousel-prev',
key: 'left'
},
//try if this fires after slide event ends
onAfter: function () {
var src = $(this).find('img').attr('src');
var img = $(this).closest('.carousel.property').find('.preview img');
img.attr('src', src);
$('.carousel.property .content li').each(function() {
$(this).removeClass('active');
});
$(this).closest('li').addClass('active');
}
});
}
if ($('.carousel-wrapper .content ul').length !== 0) {
$('.carousel-wrapper .content ul').carouFredSel({
scroll: {
items: 1
},
auto: false,
next: {
button: '.carousel-wrapper .carousel-next',
key: 'right'
},
prev: {
button: '.carousel-wrapper .carousel-prev',
key: 'left'
}
});
}
}
There you have option auto:false
, try to set it to 'true`. 那里有
auto:false
选项,尝试将其设置为auto:false
。 And if this is the slider you use, you can check ths documentation from the link above. 并且如果您使用的是滑块,则可以从上面的链接查看这些文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.