Skip to content

Instantly share code, notes, and snippets.

@mrkkr
Created January 2, 2018 15:35
Show Gist options
  • Save mrkkr/c501c28cdf07360de29eb24e74eb6063 to your computer and use it in GitHub Desktop.
Save mrkkr/c501c28cdf07360de29eb24e74eb6063 to your computer and use it in GitHub Desktop.
efekt lazy load #js
$(document).ready(function() {
/* Every time the window is scrolled ... */
$(window).scroll( function(){
/* Check the location of each desired element */
$('.hideme').each( function(i){
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, fade it it */
if( bottom_of_window > bottom_of_object ){
$(this).animate({'opacity':'1'},500);
}
});
});
});
<style>
.hideme {
opacity:0;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment