I have n slides and 5 visible slides. I want to change something on the first active slide at one moment. I try with these two methods but this is not what I need.
I achieve this on clicking the arrows for example:
$('.slider button').click(function() {
$('.slick-active:first').css({
'background-image': 'none',
});
});
But when I use autoplay, there isn't click event so I need to call this everytime when active class is set to another set of elements, and then take the first child.
Anyone ???
Hello @msavov,
If you need a onChange callback, here is what you need to do :
1 : in your slick.js file, in the _.defaults settings (line 78), add :
customOnChange:null
2: in that same file, just before the closure of the function "Slick.prototype.slideHandler" (line 1412), add :
if(_.options.customOnChange !== null){
_.options.customOnChange.call();
}
3 : in your script, when you initiate your slider, do something like :
$('#your-slider').slick({
// your options
customOnChange: function justChanged(){
alert($('#your-slider').slickCurrentSlide());
}
});
I hope that our lovely amazing @kenwheeler will add it natively in the next version =)
Cheers,
Geoffrey
high five @Geoffrey-D
Most helpful comment
Hello @msavov,
If you need a onChange callback, here is what you need to do :
1 : in your slick.js file, in the _.defaults settings (line 78), add :
2: in that same file, just before the closure of the function "Slick.prototype.slideHandler" (line 1412), add :
if(_.options.customOnChange !== null){_.options.customOnChange.call();
}
3 : in your script, when you initiate your slider, do something like :
$('#your-slider').slick({// your options
customOnChange: function justChanged(){
alert($('#your-slider').slickCurrentSlide());
}
});
I hope that our lovely amazing @kenwheeler will add it natively in the next version =)
Cheers,
Geoffrey