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

Slider breaks when slidesToShow > number of slides #1182

Open
selrond opened this issue Apr 11, 2018 · 14 comments
Open

Slider breaks when slidesToShow > number of slides #1182

selrond opened this issue Apr 11, 2018 · 14 comments

Comments

@selrond
Copy link

selrond commented Apr 11, 2018

https://codesandbox.io/s/z3r5nopkm4

expected behavior: Slick (Add & Remove demo)

@laveesingh
Copy link
Contributor

This is not a bug. This is the intended unslick behaviour.

@twgraham
Copy link

I also have this issue. I don't understand how this is not a bug unless react-slick doesn't intend to match the features of slick? As @selrond pointed to the particular slick demo showing this, when there is less slides than the specified slidesToShow, then the slider dots and arrows disappear, but the slide still take up as much room as if there were more slides. Right now we just get some weird shaped slides (see demo by @selrond). This forces me to put in 'dummy' slides so that it shows correctly.

e.g. slidesToShow = 3, if we have 1 slide, then I should expect to see 1 slide taking up 1/3 of the slider, and no slider dots/arrows

@binary-moon
Copy link

Please see my answer on #1196

@twgraham
Copy link

@binary-moon that's definitely a workaround, but not a fix. It also doesn't work well for responsive designs e.g. you might fit 7 slides in a large screen, and 1 slide in a small screen.

@binary-moon
Copy link

binary-moon commented Apr 30, 2018

@twgraham Definitely not a fix, you are right. But it works until the devs fix it (or it looks like they prefer the current behaviour). You can easily write media queries for other screen size combinations as well.

@MickeyKay
Copy link

@akiran any plans to fix this issue?

@mustkem
Copy link

mustkem commented Oct 17, 2018

Kindly assist what to do in this case. Manual fix is the only option?

@fnebenfuehr
Copy link

fnebenfuehr commented Jan 2, 2019

Wasn't an issue in 0.21.0. Revert to this previous version to temporary fix the issue.

@andre-matulionis-ifood
Copy link

Came into the same problem today. Apparently, react-slick show both the slides and its "clones" if infinite is true and slidesToShow greater than number of slides
https://codesandbox.io/s/p7mnmvy0rx

@FSM1
Copy link

FSM1 commented Jan 16, 2019

this is all quite frustrating to deal with, and having to keep track of the number of slides provided to ensure that we do not try and show more slides is a pain.

@daton89
Copy link

daton89 commented Feb 26, 2020

In my case it's broken even if slidesToShow <= number of slides, enabling responsive options:

I have 3 slides and I want to show 1 on small screens and 2 on tablets and desktops:

  const settings: Settings = {
    dots: true,
    arrows: true,
    adaptiveHeight: true,
    infinite: false,
    lazyLoad: 'ondemand',
    slidesToShow: 2,
    slidesToScroll: 1,
    responsive: [
      {
        breakpoint: 512,
        settings: {
          slidesToShow: 1,
          arrows: false,
        },
      },
    ],
  }

So the slider render 2 slides first and then when rerender to show only 1 slide the content of the Slider is not rendered anymore. This doesn't happens if we remove arrows false to responsive settings on small screens.

@vitlcoder
Copy link

Add it to css

<style>
	.slick-track,
	.slick-list {
		width: 100%;
		min-width: 100%;
	}
</style>

@GoutamShanbhag
Copy link

@vitlcoder Thank you, this solution worked for me.

@LeVuMinhHuy
Copy link

LeVuMinhHuy commented Feb 2, 2024

hello excuse me ? any progress on this ? I have to set:

.slick-list {
    min-height: `${MY_CARD_HEIGHT}px`;
 }

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

No branches or pull requests