Created
December 8, 2013 09:32
-
-
Save agaase/7855151 to your computer and use it in GitHub Desktop.
isonscreen
This file contains 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
$.fn.isonscreen = function(context){ | |
debugger; | |
var | |
//Subtract the offset of the parent container. | |
//Will be 0 in case cont is undefined | |
tominus=0, | |
//Add the scrollTop position incase no cont is undefined. | |
toadd=0; | |
if(context){ | |
//Find if the div is itself visible | |
if(!context.isonscreen()){ | |
return false; | |
}; | |
tominus = context.offset().top; | |
}else{ | |
context = $(window); | |
toadd = context.scrollTop(); | |
} | |
if($(this).offset().top - tominus <= (toadd + context.height())){ | |
return true; | |
}; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment