Answer the question
In order to leave comments, you need to log in
How to make the function work on resize in slick slider?
Hello. There is such a problem. When the page loads, the custom select works. But if the page is made less than 1380, the select stops working (ie, in my case, if the slick rebuilds the slides). What can be done to avoid this?
Link to example
Answer the question
In order to leave comments, you need to log in
See how the slick actually works. He does a bunch of duplicate slides. And he doesn’t know exactly what you did and declared for the internal elements of the slides. You have two options, stop using the slick and use another alternative that doesn't rebuild the dom, or reinitialize your custom components every time you slick the slick. To do this, go to the documentation slick events -> afterChange.
$(window).on('resize orientationchange', function() {
$('.Ваш_элемент').slick('resize');
});
<div class="your-class">
<div><img src="https://placehold.it/350x150" class="img-responsive"></div>
<div><img src="https://placehold.it/350x150" class="img-responsive"></div>
<div><img src="https://placehold.it/350x150" class="img-responsive"></div>
</div>
$('.your-class').slick({
responsive: [
{
breakpoint: 641,
settings: "unslick"
}
],
mobileFirst: true
});
$(window).on('resize orientationchange', function() {
$('.your-class').slick('resize');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question