Skip to content

Instantly share code, notes, and snippets.

@Razenbull
Created July 23, 2015 12:11
Show Gist options
  • Save Razenbull/b250fe239e8cd264ba24 to your computer and use it in GitHub Desktop.
Save Razenbull/b250fe239e8cd264ba24 to your computer and use it in GitHub Desktop.
Test if an element is at the top of the document
/**
*
* @param $element = element offset to test against $(window).scrollTop()
* @returns {boolean}
*/
function testOffset($element) {
var windowScroll = $(window).scrollTop(),
elementOffset = $element.offset().top;
return (windowScroll >= elementOffset);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment