by Ali Juma (

  • Goal: find out if an element is visible
    • Fully visible?
    • Partially visible?
    • Entirely offscreen?
    • Sites do this with JS with bounding boxes over and over again
  • API Overview
    • var observer = new InstesectionObserver(callback, options);
    • Options:
      • root: Interseection with respect to an element or if null the viewport
      • threshold: what fraction of intersection triggers notfication
    • observer.observe(target)
  • Implementation Challenges
    • Lifetime management
      • The observer and its callback need to live as long as there are targets to observe.
        • Even if the observer no longer has any JS references
      • The callback will keep the document alive.
        • It’s easy to accidentally keep the document alive indefinitely
    • Lack of Event Loop support
Last modified 6 years ago Last modified on Oct 12, 2018 5:29:43 PM