jquery - Animate element in input and output with my current code

Asked

Viewed 62 times

0

NOTE: The site where I need to use this effect has a horizontal scroll. I need with the current code, with the code of this question didn’t work because the plugin I’m using to make the horizontal scrolling hangs.

I’m hoping that when the user clicks the div button to appear from the bottom. And when you click the hide button it will be in the other div it disappears leaving for the bottom again.

Another issue is that when the user has already executed once the action returns to normal. That if he tries to run it again it works, it’s not the case there because after executed it comes over.

Code in the codepen also.

$(document).on('click', '#mostrar', function(){
      $('.secundaria').css('display','block');
    });
    $(document).on('click', '#esconder', function(){
      $('.secundaria').css('display','none');
      $('.secundaria').removeClass('slideInUp');
      $('.secundaria').addClass('slideInDown');
    });
* {margin:0;}
.principal {background: #6EC24E;height: 100vh;z-index:1;}
.secundaria {background: #538193;height: 100vh;z-index:2;position:absolute;top: 0;width: 100%;display:none;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<div class="principal">
  <h1>Div Principal</h1>
  <button id='mostrar'>mostrar</button>
</div>
<div class="secundaria animated slideInUp">
  <h2>Div Secundária</h2>
  <button id='esconder'>esconder</button>
</div>

  • Let me get this straight, you want the first time she shows up coming in from above and out from underneath, and if the guy clicks again she shows up coming from underneath and then coming out from underneath too?

  • No, I want her to show up underneath and come out underneath. But if he ran it once if you test the code it only works the first time, then it always comes up on top. I want her to always come down. And when he hides she has to disappear with animation too.

  • Very simple just remove the line $('.secundaria').removeClass('slideInUp');

  • isn’t that the same thing as the question ? https://answall.com/a/325761/21112

  • Leandrade: Yes, this solves the second situation, but the output is without animation.

  • Pedro: It’s not the same thing that the boy asked for in the scroll bar, but I believe I can use his code to do this effect that I want.

  • It didn’t work. More details at the beginning of my question.

Show 3 more comments
No answers

Browser other questions tagged

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