Reputation: 7121
I am trying to check if the element is displayed in the div(divContent
) or not.
The starting point is: elements: 1,2,3,4 are displayed.
So why the function: checkIfInView, returns true for element number 6?
This is my jsfiddle:
http://jsfiddle.net/Ht6Ym/2971/
function checkIfInView(element){
var offset = element.offset().top - $('#divContent').scrollTop();
if(offset > $('#divContent').innerHeight){
// Not in view
return false;
}
return true;
}
thanks!
Upvotes: 1
Views: 60
Reputation: 78520
You're not calling innerHeight
. You need the parenthesis for it to execute the function. Otherwise you are evaluating against the function declaration (not sure if that's the right term for it. Correct me if I'm wrong please).
Change
if(offset > $('#divContent').innerHeight){
to
if(offset > $('#divContent').innerHeight()){
Upvotes: 4