Is it possible to use resizeObserver (or something similar) to watch the top/left position of an element?

1.8k views Asked by At

I'm attempting to have a div positioned absolutely over the top of another. The div I'm attempting to cover can change size and position based on user interaction.

I have successfully matched the size using a resizeObserver but one part that falls down is if the page above the div I'm trying to cover changes height, the resizeObserver doesn't fire to move the covering div back into place - the x/y in resizeObserver callback is always 0/0.

Is there some way to observe the x/y position of a static element?

1

There are 1 answers

0
capr On

Nope, there isn't an analog MoveObserver which would be great for implementing popups that track the position of their target, so that we don't have to poll which is currently our only option.