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

Scroll snap and slides to scroll calculations are too sensitive #649

Closed
1 task done
Tracked by #321
mozart77 opened this issue Dec 10, 2023 · 4 comments · Fixed by #659
Closed
1 task done
Tracked by #321

Scroll snap and slides to scroll calculations are too sensitive #649

mozart77 opened this issue Dec 10, 2023 · 4 comments · Fixed by #659
Labels
awaiting response Issue is awaiting feedback resolved This issue is resolved

Comments

@mozart77
Copy link

mozart77 commented Dec 10, 2023

Bug is related to

  • embla-carousel (core package)

Embla Carousel version

  • v8.0.0rc15

Describe the bug

Function scrollSnapList() returns wrong number of elements.

CodeSandbox

- The link to a CodeSandbox that demonstrates the bug clearly.

Steps to reproduce

  1. Take example with dots from Generator
  2. Remove one slide
  3. Add breakpoints in CSS to change number of slides displayed
  4. Watch the number of pages when all slides are visible. There will be 2 pages

Expected behavior

One page or none when all slides are visible

Additional context

Video:
https://github.com/davidjerleke/embla-carousel/assets/6299334/8bfdba46-2969-4411-9751-50c8b9477eaf

@mozart77 mozart77 added the bug Something isn't working label Dec 10, 2023
@mozart77
Copy link
Author

Another example if we remove max-width from container (watch the dots!)

embla2.mp4

@davidjerleke
Copy link
Owner

davidjerleke commented Dec 10, 2023

Hi @mozart77,

Thank you for your bug report. Yes I’ve actually noted this issues. They are most likely caused by the transition from reading element.getBoundingClientRect to offset dimensions (e. g. offsetWidth, offsetLeft):

I basically missed to refactor the rounding safeties used in the code. Because client rects give you floating points which is why it was needed before while offset dimensions return whole integers so this is probably causing problems now. I will look into this when possible. Thanks for creating a bug so devs can track this issue.

Best,
David

@davidjerleke davidjerleke added the investigating Issue is being looked into label Dec 17, 2023
@davidjerleke davidjerleke changed the title scrollSnapList() bug? Scroll snap and slides to scroll calculations are too sensitive Dec 19, 2023
@davidjerleke
Copy link
Owner

davidjerleke commented Dec 21, 2023

Hi @mozart77,

Would you mind testing the following CodeSandbox and see if it behaves as expected now? Please let me know if you intend to test it or not so you don't leave me hanging. Thanks!

Best,
David

davidjerleke added a commit that referenced this issue Dec 21, 2023
@davidjerleke davidjerleke added awaiting response Issue is awaiting feedback and removed investigating Issue is being looked into labels Dec 21, 2023
davidjerleke added a commit that referenced this issue Dec 22, 2023
@davidjerleke davidjerleke added resolved This issue is resolved and removed bug Something isn't working labels Dec 22, 2023
@davidjerleke
Copy link
Owner

@mozart77 a bug fix for this was just released in v8.0.0-rc16.

@davidjerleke davidjerleke mentioned this issue Dec 23, 2023
37 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Issue is awaiting feedback resolved This issue is resolved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants