Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css3 slide up, jerky animation of the content under it

Tags:

css

Following a book's code for slide up/down animation using anglularjs here is the example code: http://jsfiddle.net/bx01muha/2/

here is the css code:

.container {
    overflow: hidden;
}
.slide-tile {
    transition:all 0.5s ease-in-out;
    width:300px;    
    text-align:center;
    border: 1px solid black;
    transform: translateY(0);
}
.slide-tile.ng-hide {
    transform: translateY(-100%);
}

The problem is when the content is slide up/down the content under it moved up/down with a jerk. How to fix a css3 slide up/down so that the content under it also moves smoothly?

like image 295
coure2011 Avatar asked Nov 09 '22 17:11

coure2011


1 Answers

Why not use simple JavaScript/jQuery?

Here's my solution: http://codepen.io/n3ptun3/pen/EVJzPv/

It fixes the "jerky" issue, although it doesn't use Angular. Hope this helps!

HTML

<div>
  <div>
    <button>
      Toggle Visibility
    </button>
    <div class="container">
      <div class="slide slide-tile">
        Slide me up and down! lets see whats going on...
      </div>            
    </div>
    <h1 class="slide">Jerky</h1>
  </div>   
</div>

CSS

.container {
  overflow: hidden;
}

.slide-tile {
  transition:all 0.5s ease-in-out;
  width:300px;    
  text-align:center;
  border: 1px solid black;
  transform: translateY(0);
}

.hide {
  transform: translateY(-100%);
}

h1 {
  transition: all 0.5s ease-in-out;
}

JavaScript/jQuery

$(function(){
  $("button").click(function(){
    $(".slide").toggleClass("hide");
  });
});
like image 138
neptune Avatar answered Dec 29 '22 11:12

neptune