source/scripts/responsive-lazyload.js
function isElementVisible(el) {
  /*
   * Checks if element (or an ancestor) is hidden via style properties.
   * See https://stackoverflow.com/a/21696585/463471
   */
  const isCurrentlyVisible = el.offsetParent !== null;

  // Check if any part of the element is vertically within the viewport.
  const position = el.getBoundingClientRect();
  const wH =
    window.innerHeight ||
    /* istanbul ignore next */ document.documentElement.clientHeight;
  const isWithinViewport =
    (position.top >= 0 && position.top <= wH) ||
    (position.bottom >= 0 && position.bottom <= wH);

  return isCurrentlyVisible && isWithinViewport;
}
function isElementVisible(el) {
  /*
   * Checks if element (or an ancestor) is hidden via style properties.
   * See https://stackoverflow.com/a/21696585/463471
   */
  const isCurrentlyVisible = el.offsetParent !== null;

  // Check if any part of the element is vertically within the viewport.
  const position = el.getBoundingClientRect();
  const wH =
    window.innerHeight ||
    /* istanbul ignore next */ document.documentElement.clientHeight;
  const isWithinViewport =
    (position.top >= 0 && position.top <= wH) ||
    (position.bottom >= 0 && position.bottom <= wH);

  return isCurrentlyVisible && isWithinViewport;
}
function isElementVisible ( el ) { /*
   * Checks if element (or an ancestor) is hidden via style properties.
   * See https://stackoverflow.com/a/21696585/463471
   */ const isCurrentlyVisible = el . offsetParent !== null ; // Check if any part of the element is vertically within the viewport. const position = el . getBoundingClientRect ( ) ; const wH = window . innerHeight || /* istanbul ignore next */ document . documentElement . clientHeight ; const isWithinViewport = ( position . top >= 0 && position . top <= wH ) || ( position . bottom >= 0 && position . bottom <= wH ) ; return isCurrentlyVisible && isWithinViewport ; }
Check if an element is visible at all in the viewport.

It would be cool to use an IntersectionObserver here, but browser support
isn’t there yet: http://caniuse.com/#feat=intersectionobserver

@param  {Element} el the element to check
@return {Boolean}    `true` if the element is visible at all; `false` if not
Check if an element is visible at all in the viewport .