javascript - 如何在 materializecss 中禁用 autoslider?

标签 javascript jquery html css materialize

我试过 autoplay:falseautoStart:false 但不支持。请给我建议。

Demo Link

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

最佳答案

团队目前没有提供任何选项,您可以hack使用以下方法:

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

DEMO

注意

  • Since it is the developing version of framework you can expect this feature in future.
  • This again gets started once you click on any indicators. So I would suggest to write a click event to indicators making pause again after the slider is moved.
$('.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

关于javascript - 如何在 materializecss 中禁用 autoslider?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33993594/

相关文章:

html - 我的移动网站有奇怪的字间距我需要帮助规范化

php - 如果在左框架中单击某些页面的链接,应在右框架中打开一个页面?

php - 使用 jQuery 将 JSON 数据发送到 PHP

html - z-index 与 Chrome 上的 translate3D

javascript - 从外部链接打开 Accordion 面板

javascript - 从图像 URL 中提取颜色

javascript - jQuery .fadeOut 淡出颜色然后消失

javascript - 数组或迭代器中的每个子级都应该有一个唯一的 "key"属性。 react JS 错误

javascript - Javascript 中表格上的“保存”按钮不起作用

javascript - jQuery 奇怪的悬停事件