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

Supports custom event for navigation buttons #5832

Closed
4 tasks done
yaoguoba opened this issue Jun 29, 2022 · 1 comment
Closed
4 tasks done

Supports custom event for navigation buttons #5832

yaoguoba opened this issue Jun 29, 2022 · 1 comment

Comments

@yaoguoba
Copy link
Contributor

Clear and concise description of the problem

Now we cannot pass custom events to the next/prev button. Although we can add the click event to the button directly, it is difficult to get the status of the button. So, Could you please provide these two event interfaces.

Suggested solution

Add two props like below:

 {
    onNextNav?: () => void;
    onPrevNav?: () => void;
  }

Trigger here:

 function onPrevClick(e) {
    e.preventDefault();
    if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return;
    swiper.slidePrev();
    onPrevNav?.();
  }

  function onNextClick(e) {
    e.preventDefault();
    if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return;
    swiper.slideNext();
    onNextNav?.();
  }

Alternative

No response

Additional context

No response

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.

Would you like to open a PR for this feature?

  • I'm willing to open a PR
@yaoguoba
Copy link
Contributor Author

Any release plan for this chang?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant