I am working on a small project in which I use a smooth carousel. The problem is that I want to stop dragging in the case of the first and last item. Any ideas how to do this?
How to stop drag and drop in case of the first and last item?
var readyToDrag = true; jQuery('.responsive').slick({ dots: false, infinite: false, speed: 300, slidesToShow: 1, slidesToScroll: 1, draggable: true, onBeforeChange: function(event, slick, currentSlide, nextSlide){ if(event.currentSlide == 3){ readyToDrag = false; alert(readyToDrag); } }, draggable: readyToDrag, responsive: [{ breakpoint: 1000, settings: { slidesToShow: 2, slidesToScroll: 2, infinite: false, dots: false } }, { breakpoint: 999, settings: { slidesToShow: 2, slidesToScroll: 2, infinite: false } }, { breakpoint: 767, settings: { slidesToShow: 2, slidesToScroll: 2, infinite: false, draggable: readyToDrag, } }] });
source share