I am trying to implement a "position change" watcher to notice any changes in the component I am writing w.r.t its position based on Window.
Is there any way to watch and observe if the element's position changed (due to scroll or swipe etc) and trigger an event?
Please note this is a component. Meaning, it can sit in any level of DOM or under any container. Most of the solutions I tried (IntersectionObserver, finding the nearest scrollable container, polling etc) are too costly performance or achieve 30% of the solution at the maximum.
I can elaborate on any part of the question if it sounds too vague or ambiguous.
Thanks in advance!