我试过 autoplay:false
和 autoStart:false
但不支持。请给我建议。
$('.sliderone').slider({
full_width: true,
indicators:true,
height:400,
interval:1000,
autoplay:false
});
最佳答案
团队目前没有提供任何选项
,您可以hack
使用以下方法:
$('.sliderone').slider('pause'); //just pause the slider once its loaded
注意
- 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 toindicators
making pause again after the slider is moved.
$('.indicator-item').on('click',function(){
$('.sliderone').slider('pause');
});
更新
同样没有关于此的任何文档,但是使用 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))
});
关于javascript - 如何在 materializecss 中禁用 autoslider?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33993594/