animate.css
animate.css copied to clipboard
Showing an hidden element with opacity-animation
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
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');
});
Why animate.css has no 100% state by default? :/
You should not apply opacity: 0; in your own CSS—the animation classes will set that state by default at 0%.