Skip to content

X position doesn't update when siblings change size #9

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

Open
lewisl9029 opened this issue Feb 28, 2020 · 3 comments
Open

X position doesn't update when siblings change size #9

lewisl9029 opened this issue Feb 28, 2020 · 3 comments

Comments

@lewisl9029
Copy link

Hi, I just recently started using this library, and really enjoy it so far, but discovered one limitation with it:

https://codesandbox.io/s/fervent-maxwell-c24yg

If you take a look at the above sandbox, and try to type in the input, you'll notice that the x value doesn't get updated straight away. Once you scroll up and down, then it will get updated due to the measurement on scroll.

I'm guessing this might be a limitation of the ResizeObserver API itself? Since the element itself is not resizing?

Any ideas if there might be an API we can use in combination with ResizeObserver to get updates for changes in position?

Thanks!

@eseQ
Copy link

eseQ commented Oct 29, 2020

Any solution? @lewisl9029 @drcmda

@williaster
Copy link
Contributor

+1, we've also hit the limitation where the measured element's bounds don't update when some type of page flow change affects its position. See here https://codesandbox.io/s/frosty-rain-l90dn?file=/src/index.tsx

Jan-06-2021 17-02-01

@drcmda have you thought about this challenge much? Would be amazing to be able to detect when an element's position changes, doing this with IntersectionObserver seems tricky but might be possible.

@charkour
Copy link

Hey, this is a late response. Ran into the same limitation as @lewisl9029 and @williaster did. Was able to get the x position to update correctly by adding a React.createRef to the element and then used ref.current.getBoundingClientRect().x to get the correctly updating position when the sibling size changes.

Looking at the internal code of this lib, not sure why this is a bug, maybe because the call to getBoundingClientRect is memoized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants