naver / egjs-flicking

🎠 ♻️ Everyday 30 million people experience. It's reliable, flexible and extendable carousel.
https://naver.github.io/egjs-flicking/
MIT License
2.75k stars 128 forks source link

Hot to set resposive `panelsPerView` on different screen sizes? #852

Closed stefanobartoletti closed 6 months ago

stefanobartoletti commented 7 months ago

First of all thanks for this slider, it is very simple and easy to setup and works wonderfully.

I'm willing to set a different value for panelsPerView based on screen size, so that I only have a single panel on mobile but 3 or more on desktop views.

In the docs I can see that there are no separate options for this, does the API have a way to easily accomplish this?

I see that in the docs site homepage the "framework ready" carousel is doing this. Is it done via some particular setting?

Thanks

malangfox commented 7 months ago

Hello @stefanobartoletti.

Our component does not support this feature as an option.

I think you can implement this by updating flicking.panelsPerView when the width of the window changes, or checking the window's initial width if you want to set panelsPerView only once. I've made a demo that flicking.panelsPerView changes by window size.

Can you check if is this the implementation you wanted?

stefanobartoletti commented 7 months ago

Thanks for your reply @malangfox.

This seems to be a great solution. I will try this and see if it is good for my case, meanwhile I tried to set a maximum width on the "panel" and it achieved more or less the same thing, without having to resort to javascript.

But I will check this solution too as soon as I can, maybe it will come in handy on other cases.