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

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?



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 capr