How to make the elements appear with the mouse scrool?

Asked

Viewed 78 times

3

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 causes content to appear from a smooth transition.

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

How can I do that?

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

  • I think it’s duplicated from http://answall.com/a/16479/129

  • It’s not no. The effect is different ;)

  • Can you explain how it’s different? That is, what’s the difference that the other link doesn’t show how to do?

  • On the other link, when you launch the mouse scrool the content is already there and has its size expanded. I want the content to be hidden and when scrolling the mouse it appears in a smooth way

  • Exactly like this: https://pages.github.com/

  • 3

    Is that how you want it? http://jsfiddle.net/Lt4ojtyp/

Show 1 more comment

1 answer

0

Speak, Zkk! All right?

Checks whether that article solves your problem.

The teaching is simple and in my opinion this is the easiest method to reproduce these effects. In addition to everything he explains about the viewport, which is an important part of the logic to create this.

Hugs!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.