Fix wrap-around positioning logic to account for cellAlign, slidesToShow, & slidesToScroll #600
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When
wrapAround
is set totrue
, the 2D scrolling carousel currently does not take various params into account when determining slide positioning (both when the slides are motionless and while they are transitioning). These params includecellAlign
,slidesToShow
, andslidesToScroll
.This can lead to various bugs when any of these 3 values deviate from the demo defaults. A simple example is demonstrated in the Github issue linked below:
"The behaviour can be reproduced pretty easily with the Demo-Sandbox by changing slidesToShow to 6 and wrapAround to true, see:
https://codesandbox.io/s/admiring-lamarr-60du4"
In this example, the last 2 slides are not visible (they are positioned to the left of "slide1" off-screen).
This PR updates the slide positioning logic for the 2d scrolling carousel to account for all of these parameters when wrap-around is enabled, so that the correct slides are being shown in the right positions (barring some extreme edge cases).
Fixes #548
Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
By setting the standard demo to have
wrapAround
always set totrue
, and then playing with various combinations ofcellAlign
,slidesToShow
, andslidesToScroll
.Here is an example (without this PR's fix) of
wrapAround: true
andslidesToShow: 5
. Slide #5 is incorrectly hidden, and if you scroll around for all the variouscellAlign
values ("left", "center", "right") there are generally one or more slides being hidden at any given time that shouldn't be.https://codesandbox.io/s/sparkling-sun-ftt0u
Checklist: (Feel free to delete this section upon completion)
yarn lint
)yarn test
andyarn test-e2e
)index.d.ts