Skip to content
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

Too many Snaps on Firefox with containScroll: 'trimSnaps' #472

Closed
1 task done
Tracked by #321
mUzzzie opened this issue May 11, 2023 · 8 comments · Fixed by #477
Closed
1 task done
Tracked by #321

Too many Snaps on Firefox with containScroll: 'trimSnaps' #472

mUzzzie opened this issue May 11, 2023 · 8 comments · Fixed by #477
Labels
bug Something isn't working resolved This issue is resolved

Comments

@mUzzzie
Copy link

mUzzzie commented May 11, 2023

Bug is related to

  • embla-carousel (core package)

Embla Carousel version

  • v8.0.0-rc03

Describe the bug

When having containScroll: 'trimSnaps' enabled and setting slide width relative (e.g. 20%), embla adds empty snaps on Firefox which results in additional navigation dots and enabled arrow buttons when there is nothing to scroll. Sometimes at the beginning, sometimes at the end of the carousel. No issue on Chome or Safari.

CodeSandbox

https://codesandbox.io/s/mtj878?file=/index.html

Steps to reproduce

containScroll: 'trimSnaps', slide-width: 20%, 25% + gap, open in Firefox

Expected behavior

See Chrome

@mUzzzie mUzzzie added the bug Something isn't working label May 11, 2023
@davidjerleke
Copy link
Owner

davidjerleke commented May 11, 2023

Hi @mUzzzie,

Thanks for your bug report. This seems to be a bug in Firefox and my initial hunch is that it could be caused by how Firefox handles subpixels or similar. As you've mentioned, the Chrome/Safari behaviour is the correct behaviour.

Chrome/Safari
chrome:safari

Firefox
firefox

Feel free to investigate the code and see if you can find the culprit. This is the file that is responsible for the containScroll logic.

Best,
David

@mUzzzie
Copy link
Author

mUzzzie commented May 16, 2023

I'm afraid i'm the wrong person for javascript matters. Sorry I can't help :/
Anyway, are you planning an update regarding this matter? Love the carousel but since in my case everything depends on trimSnaps, i'd have to find another library otherwise. Thanks a lot!

@davidjerleke
Copy link
Owner

Anyway, are you planning an update regarding this matter?

@mUzzzie yes, of course. This is a bug so I will solve this. But I can’t give time estimates because I’m maintaining this lib for free so this project isn’t paying any of my bills 🙂.

Best,
David

@mUzzzie
Copy link
Author

mUzzzie commented May 16, 2023

@davidjerleke Sure, I know - That is why I'm all the more appreciating your work 🙂

@davidjerleke
Copy link
Owner

davidjerleke commented May 20, 2023

Hi @mUzzzie,

It seems like Firefox is including a lot of decimal places on numbers retrieved from element.getBoundingClientRect(). Trimming the decimal places to two or three seems to do the trick (and shouldn't cause any visually noticeable problems).

Please test this CodeSandbox and see if this is working as expected. It would also be good if you could test it in Chrome and Safari to try different slide sizes that was causing the problem in Firefox.

Best,
David

@davidjerleke davidjerleke added the investigating Issue is being looked into label May 21, 2023
@davidjerleke davidjerleke mentioned this issue May 22, 2023
37 tasks
@mUzzzie
Copy link
Author

mUzzzie commented May 23, 2023

Works perfectly in all browsers.
Thank you!

@davidjerleke davidjerleke added upcoming A feature or bug fix is on its way for this issue and removed investigating Issue is being looked into labels May 23, 2023
@davidjerleke
Copy link
Owner

davidjerleke commented May 23, 2023

Thanks for testing @mUzzzie! To be released with v8.0.0-rc05.

@davidjerleke davidjerleke linked a pull request May 23, 2023 that will close this issue
davidjerleke added a commit that referenced this issue May 24, 2023
@davidjerleke davidjerleke added resolved This issue is resolved and removed upcoming A feature or bug fix is on its way for this issue labels May 24, 2023
@davidjerleke
Copy link
Owner

@mUzzzie this has been released with v8.0.0-rc05. Thanks for this bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved This issue is resolved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants