I found a solution about this animation issue. I don't know is it work for you. But I found few coding issue in your Jsfiddle.
First codding issue.
You haven't flow the W3C rules. button is a closing tag element. It's not none closing tag element like <img /> <br /> etc.
Second codding issue.
You have to forgot to write position direction CSS property. position: fixed | absolute | sticky need to set left | right | top | bottom direction.
I tested your fiddle many times why not :active pseudo-class not work after clicked. Problem found from your first animation. animation and bounceInDown classes are contain the transform property. Your animation will not work until you remove the animation and bunceInDown classes. So I need to write a function for remove those classes.
$(function(){
$('#button').on('click', function(){
$(this).removeClass('animated bounceInDown');
});
});
When I removed those classes I seen button is disappeared because of #button opacity: is 0;. So I need opacity: 1; in #button.
$(function(){
$('#button').on('click', function(){
$(this).addClass('opacity-visible');
});
});
Now found an another issue. Issue is first click :active animation not working. Because of the first click didn't allow transform property until animation classes are removed. Then need add a class when removing those animation classes. After added new class the :active animation will work.
$(function(){
$('#button').on('click', function(){
$(this).addClass('active');
});
});
Now need to set a timeOut function for remove the active class for button back to original place for next clicked animation. Now I can write all function together.
$(function(){
$('#button').on('click', function(){
$(this).addClass('active opacity-visible');
$(this).removeClass('animated bounceInDown');
setTimeout(function(){
$('#button').removeClass('active');
}, 2000);
});
});
Checked the snipped. I hope it will help you to perform the best solution.
setTimeout( function(){
$("#button").addClass("animated bounceInDown");
}, 1000);
$(function(){
$('#button').on('click', function(){
$(this).addClass('active opacity-visible');
$(this).removeClass('animated bounceInDown');
setTimeout(function(){
$('#button').removeClass('active');
}, 2000);
});
});
*:focus{
outline: none !important;
}
*{
-webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
}
#button {
position: fixed;
background-color: green;
border: 2px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
color: white;
cursor: pointer;
height: 20%;
left: 0;
width: 20%;
top: 0;
opacity: 0;
}
#button:active{
background-color: red;
transform: translateX(50%) !important;
/* animation-name: not_existing_animation; */
}
#button.opacity-visible{
opacity: 1;
transition: transform 0.3s ease-in-out 0s;
}
#button.active{
background-color: black;
transform: translateX(50%) !important;
}
/*!
* animate.css -http://daneden.me/animate
* Version - 3.5.2
* Licensed under the MIT license - http://opensource.org/licenses/MIT
*
* Copyright (c) 2017 Daniel Eden
*/
.bounceInDown {
animation-name: bounceInDown;
opacity: 1!important;
}
.animated {
animation-duration: 1s;
animation-fill-mode: both;
}
@keyframes bounceInDown {
from, 60%, 75%, 90%, to {
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
0% {
opacity: 0;
transform: translate3d(0, -3000px, 0);
}
60% {
opacity: 1;
transform: translate3d(0, 25px, 0);
}
75% {
transform: translate3d(0, -10px, 0);
}
90% {
transform: translate3d(0, 5px, 0);
}
to {
transform: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button id="button">Click Me</button>
I suggest you to don't write :active css for this type of animation. More specification here on MDN.