I have used animate.css and jQuery as external libs. Is there a better way of doing what I have done with jQuery?
$(document).ready(function () {
$('#test li').on('click', function () {
var className = $(this).attr('class');
$('#test2 > li').each(function () {
var prodName = $(this).data('prod');
if (prodName == className) {
$('#test2 > li').removeClass('bounceInRight').addClass('bounceOutRight');
$this = $(this);
setTimeout(function () {
console.log(this);
$('#test2 > li').addClass('hide')
$this.removeClass('hide bounceOutRight').addClass('bounceInRight');
}, 400);
}
});
})
});
ul#test > li {
display: inline-block;
padding: 10px;
cursor: pointer;
}
#test {
position: fixed;
top: 0;
left: 0;
}
#test2 {
position: fixed;
top: 0;
right: 0;
list-style: none;
}
#test2 > li {
background: yellow;
width: 350px;
height: 600px;
/* transition: height 0.3s ease, width 0.2s ease;*/
overflow: hidden;
margin-top: -30px;
padding-top: 30px;
margin-right: -50px;
}
.hide {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.6/animate.min.css"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.6/animate.min.css">
<ul id="test">
<li class="a">1</li>
<li class="b">2</li>
<li class="c">3</li>
</ul>
<ul id="test2">
<li data-prod="a" class="animated">1</li>
<li data-prod="b" class="animated">2</li>
<li data-prod="c" class="animated">3</li>
</ul>