Last active
March 15, 2016 18:09
-
-
Save croucha/7e32f280644bd277607f to your computer and use it in GitHub Desktop.
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 isScrolledIntoView(element) { | |
var scrollTop = $(window).scrollTop(); | |
var scrollBottom = scrollTop + $(window).height(); | |
var elementTop = $(element).offset().top; | |
var elementBottom = elementTop + $(element).height(); | |
return ((elementBottom >= scrollTop) && (elementTop <= scrollBottom) && (elementBottom <= scrollBottom) && (elementTop >= scrollTop)); | |
} |
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
/** | |
* Determines if client scrolled past bottom of element | |
* | |
* @returns {Boolean} | |
*/ | |
function isScrolledPastBottomOfElement(selector) { | |
var element = $(selector); | |
if(element && element.length > 0) { | |
var scrollBottom = ($(window).scrollTop() + $(window).height()) - 40; | |
var elementBottom = $(element).offset().top + $(element).height(); | |
} | |
return ((scrollBottom >= elementBottom)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment