Skip to content

Instantly share code, notes, and snippets.

@baumannsven
Created July 16, 2018 11:57
Show Gist options
  • Save baumannsven/c8a0e6ee6e2c5400c23889758f331d6e to your computer and use it in GitHub Desktop.
Save baumannsven/c8a0e6ee6e2c5400c23889758f331d6e to your computer and use it in GitHub Desktop.
var isInViewport = function (elem) {
var bounding = elem.getBoundingClientRect();
return (
bounding.top >= 0 &&
bounding.left >= 0 &&
bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
bounding.right <= (window.innerWidth || document.documentElement.clientWidth)
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment