Skip to content

Instantly share code, notes, and snippets.

@alexmccabe
Created January 31, 2018 10:03
Show Gist options
  • Save alexmccabe/2a449ece251e29657aa7ca3db3ab2990 to your computer and use it in GitHub Desktop.
Save alexmccabe/2a449ece251e29657aa7ca3db3ab2990 to your computer and use it in GitHub Desktop.
export default function (element, threshold) {
threshold = threshold || 0;
var elementTop = element.offsetTop;
var elementBottom = elementTop + element.clientHeight;
var viewportTop = window.scrollY;
var viewportBottom = viewportTop + window.innerHeight;
return elementBottom > viewportTop && elementTop < viewportBottom;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment