Change slidesToShow on client sliders

edited May 2019 in BeBuilder
The client-sliders show currently only three items in a row but I will display more than them. 
In addition I will change options from the slider.

Currently I use the following hack temporarily. SetTimeout is very poor, maybe you know a better way with global events.

<script>

jQuery(function() {

var $mql = window.matchMedia("(min-width: 998px)").matches;

window.setTimeout(function(){

var $clients = jQuery('.clients_slider_ul'); 

if($mql) {
$clients.slick('slickSetOption', 'arrows', 0);
$clients.slick('slickSetOption', 'autoplay', 1);
$clients.slick('slickSetOption', 'autoplaySpeed', 2000);
$clients.slick('slickSetOption', 'slidesToShow', 6); 
$clients.slick('slickSetOption', 'slidesToScroll', 4); 
$clients.slick('refresh');
}

jQuery(window).on('resize', function(){
if($mql) {
$clients.slick('slickSetOption', 'arrows', 0);
$clients.slick('slickSetOption', 'autoplay', 1);
$clients.slick('slickSetOption', 'autoplaySpeed', 2000);
$clients.slick('slickSetOption', 'slidesToShow', 6); 
$clients.slick('slickSetOption', 'slidesToScroll', 4); 
$clients.slick('refresh');
}
});

}, 900);

});
</script>


Comments

Sign In or Register to comment.