-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Description
Comparing to the current scroll-event based approach, native IntersectionObserver provides the following benefit:
- More performant. The current approach invokes calculation on every scroll event. InOb only invokes calculation when intersect boundary has been crossed.
- More accurate visibility tracking. Because the current approach doesn't take DOM mutation into consideration, hence is not accurate. InOb will take care of it.
- Work inside xorigin iframe, such as the case of
amp-inabox(I2I: Implement amp-inabox, an AMP page living inside a non-scroll-able x-origin iframe #5700), where we can't use the current scroll-event based approach.
Note: IntersectionObserver only fires when the intersection is crossing a list of pre-specified thresholds, hence we will not have exact value for metrics minVisiblePercentage and maxVisiblePercentage. We decided to approximate the values using thresholds of [0, 0.05, 0.1, ..., 1]. See discussion here: #5942
Reactions are currently unavailable