Well, I have the following code:
<head>
<style>
body,html,div {
margin:0;
padding:0;
width:1050px;
height:69px;
position:relative;
}
#anim {
background:url('https://csgopolygon.com/img/cases.png?v=222') 0 0;
background-size:300% 100%;
}
#ponteiro{
background-color:yellow;
height:69px;
width:5px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
</head>
<div id="anim">
<center>
<div id="ponteiro">
</div>
</center>
</div>
<button onclick="goncalo()">Rodar!</button>
<script type="text/javascript">
function goncalo(){
var ola = Math.floor(Math.random() * 500) + 150 +'%';
$('#anim').animate({'background-position-x': ola},8000,'easeOutCubic');
}
</script>
When I enter the page and click on Run !, it works the way I want it, but then if I do not give f5 on the same page and click on it, it does not have the same effect or instead of "turning from left to the right "wheel runs from right to left. How can I do so that at the end of the "Rotate" effect, update the function so that you do not have to give f5?
Thank you.