Closed thomas-ecrubox closed 1 year ago
Hi @thomas-ecrubox,
When it has 3 slides, there is no bug, but if it has 2 slides, slide direction is not correct.
Based on your bug description, I'm not sure I'm following why this would be a bug. What do you mean by correct? This is what the docs say about scrollTo()
:
If loop is enabled, Embla Carousel will choose the closest way to the target snap point.
Maybe it's just not the behaviour you expect? Here's the definition of scrollTo()
. As you can see, the third parameter is direction:
function scrollTo(index: number, jump?: boolean, direction?: number): void {
// ...
}
Best, David
Thanks for your help. Let me know direction parameter in detail.
0 or undefined, the carousel will decide the direction by finding the closest way to its target. -1 scrolls forward. 1 scrolls backward.
Is that right?
@thomas-ecrubox yes that's correct.
@thomas-ecrubox did it solve your problem?
This is issue is same as closed issue https://github.com/davidjerleke/embla-carousel/issues/109.
My carousel has 2 slides. When it has 3 slides, there is no bug, but if it has 2 slides, slide direction is not correct.
I have tried with what @davidjerleke said, but it doesn't work. https://www.embla-carousel.com/api/methods/#scrollto As far as I know, second parameter is jump and it's datatype is boolean. So if it is set -1, scrollTo function is recognized second parameter to be true.
Best regards