Created
          January 14, 2014 12:20 
        
      - 
      
 - 
        
Save ronnyhaase/8417457 to your computer and use it in GitHub Desktop.  
    Tests if scroll position is at an elements bottom (uses jQuery)
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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