Created
November 27, 2015 18:37
-
-
Save sectsect/9777ae661d3b5a19fda5 to your computer and use it in GitHub Desktop.
inview.js
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
jQuery(function(){ | |
var wrap = "#" + thisPanelId + ' .postcontent-inner'; | |
var wrapHeight = jQuery(wrap).outerHeight(true); | |
var container = "#" + thisPanelId + ' .postcontent-box'; | |
var target = "#" + thisPanelId + ' .postcontent-box .sec-post'; | |
var offset = wrapHeight * 0.25; // 25% Height | |
jQuery(target).first().addClass("inview"); | |
jQuery(target).each(function(){ | |
var pTop = jQuery(this).position().top - wrapHeight + offset; | |
var pBtm = jQuery(this).position().top + jQuery(this).outerHeight(true) - offset; | |
var thisid = jQuery(this).attr("id"); | |
jQuery(container).scroll(function(){ | |
var y = jQuery(this).scrollTop(); | |
if(y > pTop){ | |
jQuery("#" + thisid).addClass("inview"); | |
} | |
if(y < pTop || y > pBtm){ | |
jQuery("#" + thisid).removeClass("inview"); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment