Created
April 8, 2018 14:56
-
-
Save laocoi/fc3d7f8beff66fb00f58c2b8f5e1adff to your computer and use it in GitHub Desktop.
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
$(allInView); | |
$(window).scroll(allInView); | |
function isScrolledIntoView(elem) { | |
var docViewTop = $(window).scrollTop(); | |
var docViewBottom = docViewTop + $(window).height(); | |
var elemTop = $(elem).offset().top; | |
var elemBottom = elemTop + $(elem).height(); | |
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); | |
} | |
var inited = false; | |
function allInView() { | |
if (inited) { | |
return | |
} | |
if (isScrolledIntoView($(".postads"))){ | |
alert('hù'); | |
inited = true; | |
init(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment