Skip to content

Instantly share code, notes, and snippets.

@joelcardinal
Last active April 4, 2019 02:08
Show Gist options
  • Save joelcardinal/ecb26d8856a1023cbe4539a2492315d0 to your computer and use it in GitHub Desktop.
Save joelcardinal/ecb26d8856a1023cbe4539a2492315d0 to your computer and use it in GitHub Desktop.
Get's element offset from bottom of page to bottom of given element. Useful for test automation to determine if pixel tags are pushing up your footer.
(function(){
var el = document.querySelector('.footer-wrapper'),
rect = el.getBoundingClientRect(),
scrollTopOffset = window.pageYOffset || document.documentElement.scrollTop,
offsetFromBottom = document.documentElement.scrollHeight - (rect.top + scrollTopOffset + rect.height);
return offsetFromBottom > 0;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment