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

Fix initial slide index shift with centeredSlides and slidesPerView auto #7319

Merged
merged 1 commit into from Feb 27, 2024

Conversation

yasuhiro-yamamoto
Copy link
Contributor

  • Originally observed issue when initialSlide was 0 but reproduced in other cases(fix: initialSlide #7216 #7228 )
  • Investigation found activeColIndexWithShift calculation in loopFix.mjs was adding 0.5 when centeredSlides true, causing slidesPrepended to be decimal number in some cases
  • Non-integer slidesPrepended value then gets rounded down in snapIndex calculation in slideTo.mjs, causing initial slide index to be less than intended
  • Fix by using Math.ceil to round up the slide index variable passed to the slideTo method as argument in loopFix.mjs, ensuring an integer index value is passed to slideTo

- Originally observed issue when initialSlide was 0 but reproduced in other cases
- Investigation found activeColIndexWithShift calculation in loopFix.mjs was adding 0.5 when centeredSlides true, causing slidesPrepended to be decimal number in some cases
- Non-integer slidesPrepended value then gets rounded down in snapIndex calculation in slideTo.mjs, causing initial slide index to be less than intended
- Fix by using Math.ceil to round up the slide index variable passed to the slideTo method as argument in loopFix.mjs, ensuring an integer index value is passed to slideTo
@nolimits4web nolimits4web merged commit cae9c2d into nolimits4web:master Feb 27, 2024
3 checks passed
@nolimits4web
Copy link
Owner

Thanks!

@yasuhiro-yamamoto yasuhiro-yamamoto deleted the fix/7216 branch February 27, 2024 10:33
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

Successfully merging this pull request may close these issues.

None yet

2 participants