Skip to content

Scroll lock when zoomed in or higher display DPI scaling is used #10

@abdonkov

Description

@abdonkov

On certain zoom levels or higher display DPI scaling your scroll to bottom functionality can hang (go into infinite loop I guess) and thus lock the scrolling (always trying to scroll to the bottom).

You can see it in your own demo: https://compulim.github.io/react-scroll-to-bottom/

I have FullHD (1920x1080) monitor and use normal (100%) windows display scaling.
When setting the Chrome browser zoom level to 110% and 125% and clicking the scroll to bottom button, the scroll is locked and trying to scroll to the bottom infinitely.

(Page refresh may be needed after changing the zoom on some zoom levels).
Also tested with Edge on your demo but was not able to reproduce it even though it happened when I was using it. It can depend on the element height also for sure.

When custom display scaling is used or simulated with the browser zoom the Element.scrollTop property can be a decimal as described on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop

I guess you have a problem in the check when the element has scrolled to the bottom and it keeps trying to do it infinitely. Also I was able to reproduce it only with the scroll to bottom functionality and not with the scroll to top so it could be because of scrollTop not being an integer when an element is scrolled to the bottom.

This became more of an essay, but you got the point hopefully :).

PS (image with 110% zoom):
image
upper temp1.scrollTop is after scrolling to bottom with the mouse wheel
lower is after clicking your scroll to bottom
Note: how the upper is higher than scrollHeight - clientHeight

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions