I'm having trouble repositioning elements that sometimes should have transitions, sometimes not.
The actions works fine isolated but the view doesn't seem to update half-way in the combined action. What's the solution?
$(document).ready(function() {
$('#goLeft').on('click',function() {
$('#box').removeClass('soft');
$('#box').css('left','300px');
});
$('#goRight').on('click',function() {
$('#box').addClass('soft');
$('#box').css('left','400px');
});
$('#goLeftAndRight').on('click',function() {
//copy
$('#box').removeClass('soft');
$('#box').css('left','300px');
//Need for timeout?
//copy
$('#box').addClass('soft');
$('#box').css('left','400px');
});
});
h2 {
cursor:pointer;
}
#box {
position: fixed;
top:100px;
left:400px;
height:100px;
width:100px;
background-color:#358;
}
#box p {
padding:5px;
color:#fff;
text-align:center;
}
.soft {
transition: all 0.3s ease-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
<body>
<h2 id="goLeft">jump left</h2>
<h2 id="goRight">slide right</h2>
<h2 id="goLeftAndRight">jump left and slide right</h2>
<div id="box"><p>use headers to move</div>
</body>
</html>