Snippets Collections
/* 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)
  );
}
star

Tue Jan 12 2021 16:51:24 GMT+0000 (Coordinated Universal Time)

#viewport #visibility

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension