davidjerleke / embla-carousel

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

[Bug]: Bad scroll progress reporting when loop = true #861

Closed glomotion closed 1 month ago

glomotion commented 1 month ago

Which variants of Embla Carousel are you using?

Steps to reproduce

The bug occurs when I use the loop: true option, and try to visualise scroll progress. reproduction codesandbox

slide to the 5th (the very last) slide, and emblaApi.scrollProgress() returns ~0.8%

Expected Behavior

When you scroll to the 5th slide, the progress should be reported as 100%, as the 5th slide is the last.

Additional Context

No response

What browsers are you seeing the problem on?

Chrome, Safari

Version

8.0.3

CodeSandbox

Sandbox

Before submitting

davidjerleke commented 1 month ago

@glomotion this is not a bug, it’s expected behavior. The scroll progress is calculated based on the scrollable length of the carousel, which when loop is enabled also includes the distance from the last slide to the first.

On a side note I think your sandbox is private because I can't access it.