Created
March 26, 2015 13:50
-
-
Save vermilion1/05da388af026c66d704b 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
/** | |
* Check if element fully visible. | |
* @param {jQuery} $el. | |
* @returns {boolean} Is visible or not. | |
*/ | |
isScrolledIntoView: function ($el) { | |
var $window = $(window); | |
var docViewTop = $window.scrollTop(); | |
var docViewBottom = docViewTop + $window.height(); | |
var elemTop = $el.offset().top; | |
var elemBottom = elemTop + $el.height(); | |
return (elemBottom <= docViewBottom) && (elemTop >= docViewTop); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment