$(document).ready(function(){ $(window).on('scroll', function () { var elmt = $('.from-left, .from-right'); var topImg = $('.from-left, .from-right').offset().top; var scroll = $(window).scrollTop(); $(elmt).each(function() { var topImg = $(this).offset().top - 300; if ( topImg < scroll ) { $(this).css("transform", "translate(0,0)"); $(this).css("opacity", "1"); }; }); }); });

.from-right, .from-left { opacity: 0; transition: transform 1s ease-in-out, opacity 0.5s ease-in-out; } .from-right { transform: translate(50px,-30px); } .from-left { transform: translate(-50px,-30px); }

Liens