I have a script that animates from zero to its value. Is it possible to increment this number by more than one at a time?
e.g 1, 5, 10, 15...... 100
jQuery({ countNum: 0 }).animate({
countNum: jQuery('.ticker').text()
}, {
duration: 2000,
easing: 'swing',
step: function() {
jQuery('.ticker').text((Math.floor(this.countNum)));
},
complete: function() {
jQuery('.ticker').text((Math.floor(this.countNum)));
},
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="ticker">100</div>
You can do it like this: HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="ticker">100</div>
JS:
jQuery({ countNum: 0 }).animate(
{
countNum: jQuery(".ticker").text()/5
},
{
duration: 4000,
easing: "linear",
step: function () {
jQuery(".ticker").text(Math.floor(this.countNum)*5);
},
complete: function () {
jQuery(".ticker").text(Math.floor(this.countNum)*5);
}
}
);