myFun = () => {
$('.test').animate({ now: 100}, {
duration: 1000,
complete: function() {
now = 0;
},
step: function(now) {
console.log(now);
}
});
}
myFun();
myFun();
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<div class="test"></div>
I've this function:
myFun = () => {
$('.test').animate({ now: 100}, {
duration: 1000,
step: function(now) {
console.log(now);
}
});
}
myFun();
myFun();
If I call it twice, the second time now remains fixed at 100. I tried to solve like this:
myFun = () => {
$('.test').animate({ now: 100}, {
duration: 1000,
complete: function() {
now = 0;
},
step: function(now) {
console.log(now);
}
});
}
but it doesn't work. How do I reset now?
(In general I need to repeat an animation with the step function)