I am facing an issue with moving and flipping a button simultaneously when clicked. I have set up two animations to happen at the same time, each with the same duration. However, only the CSS scale transform seems to be working while using both jQuery's animate method and the CSS transition effect. When I remove one of the animations, the other one works perfectly.
// identifying elements
var button = $("button");
// handling click event
button.on("click", function() {
button.css({
"transform": "scaleX(0)"
});
// the problem: the following animation is not visible
button.animate({
"top": "-100px" // I even tried without "px"
}, 0.15 * 1000);
});
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
button {
background: #0084ff;
border: none;
border-radius: 5px;
padding: 8px 14px;
font-size: 15px;
color: #fff;
position: relative;
transition: all 0.15s;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
<p>Hello World</p>
<button>Click me</button>
</div>
The JSFiddle illustrating this issue can be found here.
Appreciate any help on this matter.