kenwheeler / slick

the last carousel you'll ever need
kenwheeler.github.io/slick
MIT License
28.37k stars 5.88k forks source link

automatic responsive breakpoints #3784

Open lingtalfi opened 5 years ago

lingtalfi commented 5 years ago

Hi, I know this has already been evoked by guyisra in this post: https://github.com/kenwheeler/slick/issues/157. However the post is from Apr 19, 2014, and so I wanted to reiterate the request, see if I get the same answer.

Basically, I've just set a slick carousel for a bootstrap template, and my slick code looks like this:

        $('.slick-product-gallery').slick({
            infinite: true,
            slidesToShow: 6,
            slidesToScroll: 6,
            responsive: [
                {
                    breakpoint: 1861,
                    settings: {
                        slidesToShow: 5,
                        slidesToScroll: 5
                    }
                },
                {
                    breakpoint: 1652,
                    settings: {
                        slidesToShow: 4,
                        slidesToScroll: 4
                    }
                },
                {
                    breakpoint: 1431,
                    settings: {
                        slidesToShow: 3,
                        slidesToScroll: 3
                    }
                },
                {
                    breakpoint: 1213,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 2
                    }
                },
                {
                    breakpoint: 992,
                    settings: {
                        slidesToShow: 4,
                        slidesToScroll: 4
                    }
                },
                {
                    breakpoint: 921,
                    settings: {
                        slidesToShow: 3,
                        slidesToScroll: 3
                    }
                },
                {
                    breakpoint: 768,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 2
                    }
                },
                {
                    breakpoint: 767,
                    settings: {
                        slidesToShow: 6,
                        slidesToScroll: 6
                    }
                },
                {
                    breakpoint: 618,
                    settings: {
                        slidesToShow: 5,
                        slidesToScroll: 5
                    }
                },
                {
                    breakpoint: 536,
                    settings: {
                        slidesToShow: 4,
                        slidesToScroll: 4
                    }
                },
                {
                    breakpoint: 460,
                    settings: {
                        slidesToShow: 3,
                        slidesToScroll: 3
                    }
                },
                {
                    breakpoint: 376,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 2
                    }
                },
            ]
        });

So it needs quite a lot of attention to set the slick carousel correctly, plus, if I add other responsive components in the page, I might need to rework this particular instance again.

And so I couldn't help but thinking that all I needed was a slick carousel that would calculate the responsiveness itself, based on the item's width and container basically.

I've got the intuition that it could be done using simple maths, so, provided this use case, would it be possible to implement such an "autopilot" slick feature ?

So that the developer plugs it in, and it's responsive by nature.

The feature I'm dreaming of here is quite logical in fact: the user wants to create a slick carousel which displays the maximum number of items, no matter what.

This actually doesn't depend on the screen size, but just on the container size and the items' widths. So maybe it could be named something else than "responsive", so that the two concepts don't conflict, maybe auto-width?

Hope this makes sense.

ahmadalfy commented 5 years ago

What you’re asking for could be extremely difficult to implement or extremely simple according to to how do you expect the script to work.

Maybe define a minimum width for the item and whatever fit it?