Closed pensan closed 10 years ago
Hi, Sorry but no, it is not possible. And not sure how to implement this manually
Thank you for your quick response.
May be you could add a function/parameter to prevent swipeNext/swipePrev from executing? So it would be possible to call this from within onTouchEnd.
Can you show me an example where is such option will be useful, i just don't get it))
Sorry for the late reply.
If you take this demo for example. http://www.idangero.us/sliders/swiper/demos/main-demos/16-visibility-api.html
I would like to start on slide Nr.2 (which is already possible), but I want to prevent the user from scrolling back to Nr.1. Also at the last slides, Nr.5 should be allowed, Nr.6 not.
Nr.1 and Nr.6 will be some images which are larger then the visible area, they are just for styling purposes.
Hello, Example: just add a class to the slide that you do not want to be able to slide to, like class="preventSlideTo" and on onSlideChangeStart:function(){ control if the element have the class "preventSlideTo" and prevent anim } What it could be implement as a default function is, something like other sliders do, onBeforeSlideChangeStart / onBeforeSlideChangeEnd, this could be a nice feature
EDIT: or onSlideChangeEnd:function(){ control if the element have the class "preventSlideTo" and detect direction to know if you need to call swipeNext() or a swipePrev() }
@henriquetorres much easier, don't forget that there is a swiper-no-swiping class that disable swiping on this class, closing this issue
it is too late. but it may help others. I had a similar issue. Issue/Problem: I have [x] no of slides and [n] number of slide disabled. (x>n) Expected behavior: user can see the disabled slide number in the pagination section but not able to click or see those disabled slides.
Solution: File: Swiper.js Define two new classes under the default parameters setting
i did not test all the possible scenarios but served my purpose. Enjoy!!
just do like this man..
add this code
touchRatio: 0,
slideToClickedSlide: true,
will disable touch slide and enable click function slide
var swiper = new Swiper('.the-quiz', {
pagination: '.swiper-pagination',
paginationClickable: false,
touchMoveStopPropagation:false,
simulateTouch : false,
allowSwipeToNext: true,
allowSwipeToPrev: true,
allowPageScroll: "auto ",
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
touchRatio: 0,
slideToClickedSlide: true,
});
thanks
I was able to prevent a user to swipe after a certain slide using this code:
// Example: I have n slides and I want to prevent SlideNext after the 5th slide
mySwiper.on('slideNextTransitionStart', function () { var stop_at = 5; var ri = swiper.realIndex;
if (ri == stop_at) { this.allowSlideNext = 0; } else { this.allowSlideNext = 1; } });
mySwiper.on('slidePrevTransitionEnd', function () { // If you go back to the prev slide, you'll be able again to swipe to the next slide this.allowSlideNext = 1; });
Hi,
is there a way to disable a slide? For example I don't want a user to be able to swipe to the last slide. The slide will be visible, but not in the center. So swiping forward should be disabled on the slide before the last.
Thank you in advance, pensan