Hello I work on create simple animation on scroll, this animation depend on animate.css Library but there are two problems.
First Problem:
That I need to run the animation on user scroll to bottom only.
Second Problem:
That is there are a strange animation on I scroll, The animation is not work well you can note this if you run the code snippet.
Here my code
$(function () {
var $animation_elements = $('.myDiv');
$(window).on('scroll resize', function () {
var viewportHeight = $(window).height();
$animation_elements.each(function () {
var $el = $(this);
var position = this.getBoundingClientRect(); // This Function Will Return With object Contains top left Width Height
if (position.top > viewportHeight || position.bottom < 0) {
this.inView && $el.removeClass('animated bounceIn');
this.inView = false;
} else {
!this.inView && $el.addClass('animated bounceIn');
this.inView = true;
}
});
});
});
body{
height:4000px;
margin-top:800px;
}
.myContainer{
width:1000px;
margin:50px auto;
}
.myContainer .myDiv {
width: 400px;
height: 200px;
margin: auto;
background-color: #00e675;
-moz-animation-duration: 5s !important;
-o-animation-duration: 5s !important;
-webkit-animation-duration: 5s !important;
animation-duration: 5s !important;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="myContainer">
<div class="myDiv">
</div>
</div>
Note: Please run code snippet in full page.