I am facing difficulty in adjusting elements that require transitions at times and not at other times.
The individual actions work fine but when combined, the view does not update properly halfway through. What could be a possible 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>