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

onSlideChange api called twice with diff real indexes after a loop #7360

Closed
5 of 6 tasks
ArtemOstapov opened this issue Mar 8, 2024 · 4 comments
Closed
5 of 6 tasks
Labels
React t0ggles Linked to the t0ggles task

Comments

@ArtemOstapov
Copy link

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/devbox/swiper-react-infinite-loop-forked-34sp8c?file=%2Fsrc%2FApp.jsx%3A36%2C15

Bug description

I'm trying to do some code with certain slides in a loop. First loop is OK and realIndex is working fine in onSlideChange api and as expected.
But after a loop onSlideChange api is called twice for one SlideChange with different realIndex numbers.

Here is a console log of it:
processSlideChange 1
processSlideChange 2
processSlideChange 3
processSlideChange 4
processSlideChange 5
processSlideChange 6
processSlideChange 7
processSlideChange 8
processSlideChange 8
processSlideChange 0
processSlideChange 0
processSlideChange 1
processSlideChange 1
processSlideChange 2
processSlideChange 2
processSlideChange 3
...

tell me plz how can I use realIndex only once in onSlideChange after a loop without any additional hacking/crutch ?
tnx in advance

Expected Behavior

indexing of slides should be the next:
processSlideChange 1
processSlideChange 2
...
processSlideChange 7
processSlideChange 8
processSlideChange 0
processSlideChange 1
processSlideChange 2
...
processSlideChange 7
processSlideChange 8
...

Actual Behavior

processSlideChange 1
processSlideChange 2
...
processSlideChange 7
processSlideChange 8
processSlideChange 8
processSlideChange 0
processSlideChange 0
processSlideChange 1
processSlideChange 1
processSlideChange 2
processSlideChange 2
processSlideChange 3

Swiper version

11.0.7

Platform/Target and Browser Versions

windows/Chrome

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
@nolimits4web
Copy link
Owner

t0ggles-create swiper

Copy link

t0ggles bot commented Mar 19, 2024

Task nolimits4web/SWIPER-71 was created

t0ggles task SWIPER-71

@nolimits4web nolimits4web added the t0ggles Linked to the t0ggles task label Mar 28, 2024
@nolimits4web
Copy link
Owner

This how loop works (check the DOM) and issues is not the place to ask how to do things

Copy link

t0ggles bot commented Mar 28, 2024

Task nolimits4web/SWIPER-71 status changed to Done

Repository owner locked and limited conversation to collaborators Mar 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
React t0ggles Linked to the t0ggles task
Projects
None yet
Development

No branches or pull requests

2 participants