0
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>
<script src="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 Rotate! , works the way I want, but then if I don’t give F5 on the same page and click on rotate, no longer has the same effect or instead of "turn from left to right" right to left wheel. How can I make so that at the end of the "Run" effect, update the function so that it does not have to give F5?
Thank you.
This is exactly what I needed! In 4 minutes, I mark the answer.
– Gonçalo
@Gonçalo edited with a complement, I hope it helps.
– mrlew
Perfect! , couldn’t ask for better.
– Gonçalo