html5 – How to make the elements appear with the mouse scrool?

Question:

Visibility.onVisible(function(){
	setTimeout(function(){
		$(".animar").addClass("animated fadeInDown"); }, 400);
	setTimeout(function(){
		$(".animar2").addClass("animated fadeInDown"); }, 800);
	setTimeout(function(){
		$(".animar3").addClass("animated fadeInDown"); }, 1200);
	setTimeout(function(){
		$(".animar4").addClass("animated fadeInDown"); }, 1600);
	setTimeout(function(){
		$(".animar5").addClass("animated fadeInDown"); }, 2000);
});
html,
body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}
.animar,
.animar2,
.animar3,
.animar4,
.animar5 {
  opacity: 0;
}
.animated {
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}
@-webkit-keyframes fadeInDown {
  from {
    opacity: 0;
    -webkit-transform: translate3d(0, -100%, 0);
    transform: translate3d(0, -100%, 0);
  }
  to {
    opacity: 1;
    -webkit-transform: none;
    transform: none;
  }
}
@keyframes fadeInDown {
  from {
    opacity: 0;
    -webkit-transform: translate3d(0, -100%, 0);
    transform: translate3d(0, -100%, 0);
  }
  to {
    opacity: 1;
    -webkit-transform: none;
    transform: none;
  }
}
.fadeInDown {
  -webkit-animation-name: fadeInDown;
  animation-name: fadeInDown;
}
<script src="http://cdnjs.cloudflare.com/ajax/libs/visibility.js/1.2.3/visibility.min.js"></script>



<div class="container">
  <div class="col-md-12" style="padding: 150px; background-color: red">
    <p class="animar">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
      dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
  </div>
  <div class="col-md-12" style="padding: 150px; background-color: green">
    <p class="animar2">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
      dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
  </div>
  <div class="col-md-12" style="padding: 150px; background-color: white">
    <p class="animar3">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
      dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
  </div>
  <div class="col-md-12" style="padding: 150px; background-color: yellow">
    <p class="animar4">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
      dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
  </div>
  <div class="col-md-12" style="padding: 150px; background-color: orange">
    <p class="animar5">"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
      dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
  </div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

This code uses a library called VisibilityJS . Every time I reload the page it makes content appear a smooth transition.

I want to make the content only appear with the scrool/scroll of the mouse.
like in this example

How can I do this?

If there is another plugin that does this also accepted. My goal is to learn how to put this animation on any website.

Answer:

Speak up, Zkk! How is everything?

Check if this article solves your problem.

The teaching is simple and in my opinion this is the easiest method to reproduce these effects. On top of that it explains about the viewport, which is an important part of the logic to create this.

Hugs!

Scroll to Top