I am trying to animaiate a circle in a square motion animation using jQuery and css transition, for some reason only the last css jquery animtion works. i know i can accomplish a series of animations with jQuery animate function but i want to now if its possible to do it with css transition and jquery ,any suggestions how to fix it
$(document).ready(function(){
$('h1').click(function(){
if($('.container').hasClass('isMoved')){
$('.container').css({
'-webkit-transform': 'translatex(0px)',
'opacity' : '1'
});
$('.container').removeClass('isMoved')
}else{
$('.container').css({
'-webkit-transform': 'translatex(350px) ',
'opacity' : '0.6'
});
$('.container').css({
'-webkit-transform': 'translatey(350px) ',
'opacity' : '0.6'
});
$('.container').css({
'-webkit-transform': 'translatex(0px) ',
'opacity' : '0.6'
});
$('.container').css({
'-webkit-transform': 'translatey(0px) ',
'opacity' : '0.6'
});
$('.container').addClass('isMoved');
}
});
});
<style>
body{
background-color:darkcyan;
}
.container{
width:100px;
height:100px;
border-radius: 100px;
background-color:aquamarine;
position:absolute;
-webkit-transition: all 2s ease-in-out;
}
</style>
</head>
<body>
<h1>Click</h1>
<div class='container'>
</div>
</body>