Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not slide to previous slide with allowSlideNext: false with RTL mode #6737

Closed
5 of 6 tasks
mohitmilindthakur opened this issue Jun 6, 2023 · 0 comments
Closed
5 of 6 tasks

Comments

@mohitmilindthakur
Copy link

Check that this is really a bug

  • I confirm

Reproduction link

https://07m9l7.csb.app/

Bug description

The following issue is only in the RTL mode
If we have allowSlideNext set to false in the RTL mode, the back navigation button (or swipe on mobile) does not work beyond 2nd slide. Even though allowSlidePrev is true. I have the following use case for above scenario

The user should not be able to go to next slide unless a certain action is performed on current slide. Once that action is performed, user is automatically taken to next slide. To achieve this we are setting allowSlideNext to false and once that particular action is performed we are setting allowSlideNext to true and then calling swiper.nextSlide() function and then setting back allowSlideNext to false. This works well in LTR (left to right) mode but does not in RTL (right to left) mode. This also does not work only from the 3rd slide. If we are on 2nd slide and go back, it goes back to 1st but if we are on 3rd slide and then click previous button, it stays on the same slide and does not go back to 2nd slide.

Although I did not do a deep dive in to the code but it may be doing an early return from this if condition in swiper > core > slideTo.js. The below if condition was getting true so an early return might be happening which is preventing it to go to previous slide

if (!swiper.allowSlideNext && (translate < swiper.translate) && translate < swiper.minTranslate()) {
      return false;
 }

Expected Behavior

Clicking on previous button (or swiping to previous slide) should take the user back to previous slide

Actual Behavior

Clicking on previous button (or swiping to previous slide) does not take the user to previous slide.
Note: Going back to previous slide works on 2nd slide (going from 2nd to 1st), but does not work on 3rd slide. (going from 3rd to 2nd) or from any slide to any slide beyond 2nd slide

Swiper version

9.1.1

Platform/Target and Browser Versions

macOS

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant