Sysode
Front-End Developer
Just something quick, wondering if there is a more effective/efficent way of doing this? (It was just something I wrote up quickly)
The only improvement I can see is probably assigning a class with the animations and letting the CSS deal with the animating instead of the Javascript.. Leave improvements below (apologies if it's scruffy)
Code:
$(window).scroll( function(){
$('.featured-work ul.rig li').each( function(i) {
var objBottom = $(this).position().top + $(this).outerHeight();
var windowBottom = $(window).scrollTop() + $(window).height();
if( windowBottom > objBottom ){
$(this).animate({'opacity':'1'},800);
}
});
});
The only improvement I can see is probably assigning a class with the animations and letting the CSS deal with the animating instead of the Javascript.. Leave improvements below (apologies if it's scruffy)