The
Intersection Observer API
provides a way to asynchronously observe changes in the intersection of a
target element with an ancestor element or with a top-level document's
viewport.
- Lazy-loading of images or other content as a page is scrolled.
-
Implementing "infinite scrolling" web sites, where more and more content
is loaded and rendered as you scroll, so that the user doesn't have to
flip through pages.
-
Reporting of visibility of advertisements in order to calculate ad
revenues.
-
Deciding whether or not to perform tasks or animation processes based on
whether or not the user will see the result.
Video will be played only when entire video is in viewport