Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 物化转盘滑块自动播放_Jquery_Materialize - Fatal编程技术网

Jquery 物化转盘滑块自动播放

Jquery 物化转盘滑块自动播放,jquery,materialize,Jquery,Materialize,是否有参数使物化旋转木马滑块自动播放 $('.carousel').carousel(); 例如(此参数不起作用): 谢谢大家! 我解决了这个问题: $('.carousel').carousel({ padding: 200 }); autoplay(); function autoplay() { $('.carousel').carousel('next'); setTimeout(autoplay, 4500); } 我也有同样的问题,我也像你一样实施

是否有参数使物化旋转木马滑块自动播放

$('.carousel').carousel();
例如(此参数不起作用):


谢谢大家!

我解决了这个问题:

$('.carousel').carousel({
    padding: 200    
});
autoplay();
function autoplay() {
    $('.carousel').carousel('next');
    setTimeout(autoplay, 4500);
}

我也有同样的问题,我也像你一样实施同样的解决方案。我刚刚添加了另一个功能,在单击向右或向左箭头(按钮)后重新启动间隔

我的右箭头的类别是。fa angle right(fontawsome)和left。fa angle left

因此,我的转盘调用函数如下所示:

$('.carousel').carousel({
   full_width: true,
   time_constant: 100
 });

 var carouselAutoplay = setInterval(function() {
   $('.fa-angle-right').click();
 }, 7000);

 $('.fa-angle-right').click(function() {
   $('.carousel').carousel('next');
   clearInterval(carouselAutoplay);
   carouselAutoplay = setInterval(function() {
     $('.fa-angle-right').click();
   }, 7000);
 });
 $('.fa-angle-left').click(function() {
   $('.carousel').carousel('prev');
   clearInterval(carouselAutoplay);
   carouselAutoplay = setInterval(function() {
     $('.fa-angle-right').click();
   }, 7000);
 });

尝试像这样执行
next
方法

  $('.carousel').carousel();
  setInterval(function() {
    $('.carousel').carousel('next');
  }, 2000); // every 2 seconds

我解决了此代码的问题:

$('.carousel.carousel-slider').carousel({
   fullWidth: true,
   padding: 200
 }, setTimeout(autoplay, 4500));

 function autoplay() {
   $('.carousel').carousel('next');
   setTimeout(autoplay, 4500);
 }

您只需收听carouselonCycleTo事件,然后按如下方式重置/启用自动播放:

var carousel=jQuery('div#home carousel');
旋转木马({
全宽:对,
指标:正确,
持续时间:300,
onCycleTo:函数($current\u项,已拖动){
console.log($current_item);
停止自动播放();
startAutoplay(旋转木马);
}
});
var自动播放id;
功能startAutoplay($carousel){
自动播放id=setInterval(函数(){
$carousel.carousel('next');
},5000);//每5秒
//日志(“启动自动播放”);
}
函数stopAutoplay(){
if(自动播放id){
clearInterval(自动播放标识);
//控制台日志(“停止自动播放”);
}

}
如果用户悬停旋转木马,您还可以防止其滑动:

$('.carousel.carousel-slider').carousel({
    fullWidth: true,
    indicators: true
});

var autoplay = true;

setInterval(function() { 
    if(autoplay) $('.carousel.carousel-slider').carousel('next');
}, 4500);

$('.carousel.carousel-slider').hover(function(){ 
     autoplay = false; 
}, function(){ 
     autoplay = true; 
});

自动播放
,延迟4秒

function autoplay() {
 $('.carousel').carousel('next');
 setTimeout(autoplay, 4000);
}    
setTimeout(autoplay, 4000);

我正在使用物化css角度。这就是我做的,让它自动播放

let iCarousel = new M.Carousel(this.elCarousel.nativeElement, {
      fullWidth: true,
      indicators: true
});

// this did the trick
setInterval(() => {
   iCarousel.next();
}, 2000)

重复接受答案。将4.5秒更改为4秒不会产生新答案;
let iCarousel = new M.Carousel(this.elCarousel.nativeElement, {
      fullWidth: true,
      indicators: true
});

// this did the trick
setInterval(() => {
   iCarousel.next();
}, 2000)