animate.css icon indicating copy to clipboard operation
animate.css copied to clipboard

Showing an hidden element with opacity-animation

Open dangelion opened this issue 11 years ago • 3 comments

I've the foo element hidden, and I need to show it with zoomIn animation.

#foo {
  opacity: 0;
  ...
}
$(document).ready(function() {
    $("#foo").addClass("animated zoomIn");
});​

With the above code I see the animation and then the foo element disappears again. How can solve it?

It seems a problem like this https://github.com/daneden/animate.css/issues/37 but it doesn't solve my problem

dangelion avatar Jul 23 '15 21:07 dangelion

You should set opacity to 1 when the animation finished, you can either modify animate.css with

@keyframes zoomIn {
  0% {
    opacity: 0;
    transform: scale3d(.3, .3, .3);
  }

  50%, 100% {
    opacity: 1;
  }
}
.zoomIn {
  animation-name: zoomIn;
}

or the jQuery way

$(document).ready(function() {
    $('#foo').addClass('animated zoomIn').bind('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function(){
      $('#foo').css('opacity', '1');
});​

Doing93 avatar Jul 27 '15 09:07 Doing93

Why animate.css has no 100% state by default? :/

dangelion avatar Jul 28 '15 21:07 dangelion

You should not apply opacity: 0; in your own CSS—the animation classes will set that state by default at 0%.

daneden avatar Aug 02 '15 19:08 daneden