Skip to content

Get position with default scroll values #67

@bastienrobert

Description

@bastienrobert

I use useMeasure on a simple div element. When I refresh the page, the scroll stays at the same position after the refresh as before, both on Safari, Chrome and Firefox.
My element's position values change because it doesn't calculate the window scroll values to add the Y overflow to the top/Y and the X overflow to the left/X.
I know this is the way getBoundingClientRect works but it could be very useful to get the right position values.

I've made a small repro here and a video:
https://user-images.githubusercontent.com/14930937/145437063-1438c794-d2af-4a02-a21a-7e241c7f37d7.mov

The scroll option fix this problem but it re-render the component each time I scroll, which is not fully efficient.
Maybe it could be a good solution to pass an option for this specific behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions