JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://ricostacruz.com/jquery.transit/jquery.transit.min.js"></script>
<div class="box stop"></div>
<button>Click Me</button>
CSS
.box {
opacity: 0.8;
position: absolute;
left: 0;
top: 5%;
background: #505060;
border-radius: 1px;
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2);
margin: -16px 0 0 -16px;
width: 32px;
height: 32px;
z-index: 2;
}
.stop {
background:red;
}
JavaScript
$('button').click(function () {
if (!$('.box').hasClass('stop')) {
$('.box').stop().transition({
x: $('.box').offset().left + $('.box').width() / 2
}, 1).addClass('stop');
} else {
$('.box').transition({
x: '350px'
}, 5000).removeClass('stop');
}
});