davidjerleke / embla-carousel

A lightweight carousel library with fluid motion and great swipe precision.
https://www.embla-carousel.com
MIT License
6.3k stars 187 forks source link

[Bug]: Even amount of items per slide #982

Closed alvinnnnn21 closed 3 months ago

alvinnnnn21 commented 3 months ago

Which variants of Embla Carousel are you using?

Steps to reproduce

I tried to set my slide size to 50% width so that each slide will contain onky 2 items, but when the slide play / or i press next / drag the next slide the next slide will got cut off and only will show full item when i reach end of the items. This only occurs everytime i set to even amout of items per slide. I am sure if this is a bug or is it itended to behave this way.

Expected Behavior

Show full slide items on every amount of items per slide.

Additional Context

I have also tried...

What browsers are you seeing the problem on?

Chrome

Version

No response

CodeSandbox

No response

Before submitting

davidjerleke commented 3 months ago

@alvinnnnn21 please create a CodeSandbox demonstrating the problem. This is most likely a faulty setup on your side and if you’re looking for guidance it’s recommended to create a discussion instead.

alvinnnnn21 commented 3 months ago

i am sorry, still new with this kind of stuff.

here is the codepen to demonstrated my problem.

https://codesandbox.io/p/sandbox/carousel-qtky2c

sarussss commented 3 months ago

Hi@alvinnnnn21 maybe because the align option is set to center by default. You can try set is start

https://www.embla-carousel.com/api/options/#align

alvinnnnn21 commented 3 months ago

Hi @sarussss, i tried your suggestion and it works !! Thank you so much for the suggestion, can you help me to understand why does changing the alignment to start make it work ?

davidjerleke commented 3 months ago

Hi @alvinnnnn21,

This is because the align option controls how you want to align your scroll snaps relative to the viewport. Read about it in the docs:

If you want a visual demonstration of the align property, use the carousel generator and set the slide size to 50%. After that you can change the align option, scroll back and forth and se what it does.

And a friendly reminder, please create a new discussion if you need help. Just because the carousel isn’t behaving exactly as you would like, it doesn’t automatically mean that it’s a bug.

Thanks for understanding.

alvinnnnn21 commented 3 months ago

@davidjerleke Yeah, sorry about that—it was my mistake.