Skip to content

Instantly share code, notes, and snippets.

@kwyn
Created February 27, 2015 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwyn/7d1aed5f36051d551e74 to your computer and use it in GitHub Desktop.
Save kwyn/7d1aed5f36051d551e74 to your computer and use it in GitHub Desktop.
function trigger (match, offset, func){
var trigger_height = $(match).offset().top + offset;
var element_height = $(match).height();
$(window).on('scroll-tick', function() {
var scrolltop = $(window).scrollTop();
if(scrolltop > trigger_height && scrolltop < trigger_height + element_height){
func();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment