Advertisement
rAthus

Increment number counter animation

Jul 21st, 2020
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. incrementNumber = function($block, start, finish, duration) {
  2.     if (typeof(start)=='undefined') {
  3.         var start = 0;
  4.         if ($block.text().trim()*1)
  5.             start = $block.text().trim()*1;
  6.     }
  7.     for (var i=0; i<=duration/100; i++) {
  8.         var nb = Math.round(finish/((duration/100)/i));
  9.         setTimeout(function(nb) {
  10.             $block.html(nb);
  11.         }.bind(null,nb),i*100);
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement