Skip to content

Instantly share code, notes, and snippets.

@ronnyhaase
Created January 14, 2014 12:20
Show Gist options
  • Save ronnyhaase/8417457 to your computer and use it in GitHub Desktop.
Save ronnyhaase/8417457 to your computer and use it in GitHub Desktop.
Tests if scroll position is at an elements bottom (uses jQuery)
function isAtContainerBottom(el) {
var
$window = $(window),
$el = $(el),
viewTop = $window.scrollTop(),
viewBottom = (viewTop + $window.height()),
containerBottom = Math.floor( $el.offset().top + $el.height() ),
// amount of pre-bottom space to take into account
scrollBuffer = 150;
if ( (containerBottom - scrollBuffer) <= viewBottom ) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment