如何在materializecss中禁用autoslider?

时间:2015-11-30 07:39:00

标签: javascript jquery html css materialize

我尝试了autoplay:falseautoStart:false,但它不支持它。请建议我。

Demo Link

 $('.sliderone').slider({
    full_width: true,
    indicators:true,
    height:400,
    interval:1000,
    autoplay:false
  });

3 个答案:

答案 0 :(得分:3)

目前团队中没有提供option您可以 hack 使用以下方法:

$('.sliderone').slider('pause'); //just pause the slider once its loaded

<强> DEMO

注意

  
      
  • 由于它是框架的开发版本,您可以在将来期待此功能。
  •   
  • 点击任意indicators后再次启动。因此我建议将点击事件写入indicators暂停   移动滑块后再次。
  •   
$('.indicator-item').on('click',function(){
    $('.sliderone').slider('pause');
});

<强> DEMO

<强>更新

同样没有关于此的任何文档,但使用jquery,您可以实现以下目标:

$(".indicators .indicator-item").each(function(key,value){
    //iterate through each indicator-item
    //key will be starting from 0,1,2,3 etc., and goes to number of indicators present
    var img=$('<img/>',{
      'src':$('.slides img').eq(key).css('background-image').replace('url(','').replace(')','')
    });
    //create an image tag as above and set its src from each image's background-image property value present inside
    //.slides element and get using its index with the help of eq(key)
    //say key=0 at first iteration and when I say eq(0) this will get 1st image
    //similarly second, third and gets appended to its respective indicators
    img.appendTo($(this))
});

<强> UPDATED DEMO

答案 1 :(得分:0)

您可以编写大间隔,例如interval:1000000。它是一个拐杖,但可以帮助你。

答案 2 :(得分:-1)

$('.slider').slider({
    interval:100000
});