I know that this type of functionality is useful, but please consider the performance implications before doing anything like this. Non-native implementations (i.e. not IntersectionObserver) _always_ use properties and methods that cause style and layout calculations which have a significant performance impact on low-powered devices.
A more comprehensive list is here[1], but the main culprits are HTMLElement.offset{Width,Height}, Element.client{Width,Height}, and Window.getComputedStyle(). Avoid these, _especially_ on events like scroll. You will ruin the experience for many of your users.
and it's impossible to achieve it without probing those attributes.
some advertising libraries solve that, since the advertising industry deals in in-view ad impressions for a few years now, by being smart about when to do it. the best one is called safeFrames. others like moat detect if the user has a fast computer, abuse it to no end, and then extrapolate the results for the whole audience.
i expect all of them to move to the native APIs soon (but Android fragmentation will make it slow)
A more comprehensive list is here[1], but the main culprits are HTMLElement.offset{Width,Height}, Element.client{Width,Height}, and Window.getComputedStyle(). Avoid these, _especially_ on events like scroll. You will ruin the experience for many of your users.
[1] https://gist.github.com/paulirish/5d52fb081b3570c81e3a