I created a package for this, called rect-observer.
Internally, it creates an intersection observer with margins calculated to include only the target rect. it also uses two resize observers to deal with cases where the object or margins become invalid.
I preferred this solution to position observer presented in other answer since it works with less intersection observers and works even when the target is not in the scroll visible area.