While I can play the animation when scrolled to the view/section, the animated elements first appear and then start animation from opacity 0 to 1. It looks a bit awkward.
What have I missed in making the elements in the section to be hidden and then animate to appear when scrolled to the viewport?
<div class="myDiv"><img src="some image"></div>
.myDiv.animate .animateFromRight {
animation: fadeInRight4 1.2s both 600ms;
}
$(window).scroll(function() {
var windowBottom = $(this).scrollTop() + $(this).height();
$('.myDiv').each(function() {
var sectionTop = $(this).offset().top;
if (windowBottom > sectionTop) {
$(this).addClass('animate');
}
});
});