-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
[Bug]: Extra snapList point on some cases #707
Comments
Also, the goal is to |
@huri3l thanks for your bug report. Before I start investigating this, are you sure that shadcn/ui is using It seems like they still are using Best, |
Hi David! Yes, shadcn/ui is using I have opened this issue here because this behavior is blocking a pull request where I am implementing dots nagivation. |
@huri3l thanks for confirming. I’ll have a look when possible. Best, |
@huri3l I can confirm that this is a bug. Embla has changed from reading With offset dimensions you loose the precision that I just finished writing tests for these cases. I found two cases where this bug occurs (❌ = remove snap):
The solution to this is to add a pixel tolerance of Best, |
Nice David! It seems that this toleration is going to fix the problem. |
@huri3l would you mind testing this CodeSandbox to see if you can reproduce the problem? Another case that triggered the undesired behavior was with 10 slides 20% wide each. If you have a moment, I would appreciate if you could test that and any other relevant case you can think of too. Thanks! |
It works wonders @davidjerleke! As far as I have tested, with multiple slides and sizes, there are no problems. I have also noticed, testing in the current version of the lib, that this problem oftenly occurs when the flex-basis returns a float value. Like the I tested with other basis that also returned float and the problem was solved in this CodeSandbox too. Thanks for the fixing man! |
Thanks a lot for taking the time to test the bug fix @huri3l. Much appreciated 👍. I will release Best, |
[Bug]: Extra snapList point on some cases
@huri3l a bug fix for this was just released in |
Amazing! @davidjerleke will you update the PR to update |
@huri3l I’m not the author of that PR, @Xxsource98 is: |
Version
8.0.0-rc19
CodeSandbox
CodeSandbox Link
What browsers are you seeing the problem on?
All of the above
Steps to reproduce
The bug occurs when I am using the library shadcn/ui, which uses embla-carousel under the hood. In the CodeSandbox, I have used the same code I used and got the issue.
In the example, there is an extra step in the Dots and in the Arrows, which could be eliminated.
298121230-7eb11649-d2a4-458e-876b-3f3a2cf4e285.mov
Expected Behavior
The expected behavior is that it should have only 4 steps, and not 5, since I have 6 content in total and three visible at a time.
Additional Context
I have debugged a little bit and found out that the problem is not
canScrollNext
orcanScrollPrev
, but actually, when embla identifies how many steps it has.As you can see through the image, the snapList goes from 0 to 4, and 3 is a value really close to 1.
Is there anyway to merge this step with the last one?
I am not sure if this is a bug, but if it is not, I haven't found the correct option to use with embla-carousel to fix it. I am already using
containScroll: 'trimSnaps'
and it is still with the undesired behavior.Which variants of Embla Carousel are you using?
Before submitting
The text was updated successfully, but these errors were encountered: