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

fix(useScroll): account for rounding errors when calculating arrivedState #2051

Merged
merged 1 commit into from Aug 6, 2022
Merged

fix(useScroll): account for rounding errors when calculating arrivedState #2051

merged 1 commit into from Aug 6, 2022

Commits on Aug 6, 2022

  1. fix(useScroll): account for rounding errors when calculating arrivedS…

    …tate
    
    Sometimes when zooming the page to sizes other than 100% and scrolling a
    container all the way to the bottom right, the calculation for
    `arrivedState.right` and `arrivedState.bottom` would incorrectly say
    `false`. This is due to a [rounding error][] because `scrollTop` is a
    non-rounded number, while `scrollHeight` and `clientHeight` are rounded.
    
    Using the MDN documentation on `Element.scrollHeight` as guidance,
    this commit factors in a 1px margin of error to more accurately
    calculate `arrivedState.right` and `arrivedState.bottom`.
    
    [rounding error]: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#determine_if_an_element_has_been_totally_scrolled
    
    fix #2047
    curtgrimes committed Aug 6, 2022
    Configuration menu
    Copy the full SHA
    a0d28a7 View commit details
    Browse the repository at this point in the history