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

slidesToScroll that don't fit evenly into slideCount causes weird sliding behavior #3981

Open
SamJacobs opened this issue Jun 15, 2020 · 0 comments · May be fixed by #3982
Open

slidesToScroll that don't fit evenly into slideCount causes weird sliding behavior #3981

SamJacobs opened this issue Jun 15, 2020 · 0 comments · May be fixed by #3982

Comments

@SamJacobs
Copy link

There are two issues here, sort of packed into one. First: logic around _.slideCount % _.options.slidesToScroll !== 0 makes the slider jump randomly in some cases after animation. Second: the logic for cases around _.slideCount % _.options.slidesToScroll !== 0 seem to cause behavior that was decided arbitrarily. For instance,

if (targetSlide >= _.slideCount) {
            if (_.slideCount % _.options.slidesToScroll !== 0) {
                animSlide = 0;
            } else {
                animSlide = targetSlide - _.slideCount;
            }

why would we always want to start back over at the first slide when we cycle through pressing Next?

====================================================================

https://codepen.io/samjacobs/pen/RwrRdxR

====================================================================

Steps to reproduce the problem

a)
When using Infinite mode where _.slideCount % _.options.slidesToScroll !== 0, say 10 slides, slidesToScroll === 3,
Given the user presses previous once,
Then the math for the animation in _.getLeft does not match the math at the end of the animation from _.setPositioon, so the slider jumps to a different spot.

b)
When using Infinite mode where _.slideCount % _.options.slidesToScroll !== 0, say 10 slides, slidesToScroll === 3,
Given the user presses next to go from slide 7 to slide 10,
Then the slider animates to slide 5.

====================================================================

What is the expected behaviour?

a) Pressing previous from the first slide, with slidesToScroll being 3 and 10 slides, , I would expect to jump to slide # 8.

b) I would the slides to animate to slide 10, and then pressing again to animate to slide 3.

====================================================================

What is observed behaviour?

a) The slides animate to the correct slide, then jump to slide 5.
b) The slide animates to slide 5.

====================================================================

More Details

  • I discovered this using the latest version of react-slick.
  • Can be reproduces using 3.5.1 jquery and 1.9 slick.js in codepen
SamJacobs added a commit to SamJacobs/slick that referenced this issue Jun 15, 2020
@SamJacobs SamJacobs linked a pull request Jun 15, 2020 that will close this issue
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 a pull request may close this issue.

1 participant