Answer the question
In order to leave comments, you need to log in
Disable Slick auto-scroll if slider is scrolled off screen?
The client issued an edit, from which he slightly precipitated.
It is required that in a slider scrolled off the screen, for example, more than 500px, auto-scrolling is disabled.
How can this be done at all?
$('[data-slick]').each(function () {
var slider = $(this),
autoplay;
$(window).on('load scroll', function() {
var sliderHeight = slider.height(),
windowHeight = window.screen.height,
scroll = $(window).scrollTop(),
visibleZone = sliderHeight - scroll;
if (visibleZone <= 100) {
autoplay = false;
} else {
autoplay = true;
}
});
slider.slick({
slidesToShow: 1,
slidesToScroll: 1,
infinite: true,
autoplay: autoplay,
autoplaySpeed: 5000,
arrows: false,
dots: true,
});
});
Answer the question
In order to leave comments, you need to log in
Remember the slider number when scrolling, when scrolling back, set the active slide (slickGoTo) to slick this number.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question