is in Viewport

PHOTO EMBED

Tue Jan 12 2021 16:51:24 GMT+0000 (UTC)

Saved by @rstringa #viewport #visibility

/* Check if Module Map Instructions is in Viewport */
var isOnScreen = function (element) {
  var w = window,
        elBounds = element.getBoundingClientRect(),
        scrollTop = w.pageYOffset,
        elTop = elBounds.y + scrollTop;

  return (
     elTop < (w.innerHeight + scrollTop) &&
     elTop > (scrollTop - elBounds.height)
  );
}
content_copyCOPY