kurniaandi1

count

Jan 2nd, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. function countUp(count)
  2. {
  3. var div_by = 100,
  4. speed = Math.round(count / div_by),
  5. $display = $('.count'),
  6. run_count = 1,
  7. int_speed = 24;
  8.  
  9. var int = setInterval(function() {
  10. if(run_count < div_by){
  11. $display.text(speed * run_count);
  12. run_count++;
  13. } else if(parseInt($display.text()) < count) {
  14. var curr_count = parseInt($display.text()) + 1;
  15. $display.text(curr_count);
  16. } else {
  17. clearInterval(int);
  18. }
  19. }, int_speed);
  20. }
  21.  
  22. countUp(495);
  23.  
  24. function countUp2(count)
  25. {
  26. var div_by = 100,
  27. speed = Math.round(count / div_by),
  28. $display = $('.count2'),
  29. run_count = 1,
  30. int_speed = 24;
  31.  
  32. var int = setInterval(function() {
  33. if(run_count < div_by){
  34. $display.text(speed * run_count);
  35. run_count++;
  36. } else if(parseInt($display.text()) < count) {
  37. var curr_count = parseInt($display.text()) + 1;
  38. $display.text(curr_count);
  39. } else {
  40. clearInterval(int);
  41. }
  42. }, int_speed);
  43. }
  44.  
  45. countUp2(947);
  46.  
  47. function countUp3(count)
  48. {
  49. var div_by = 100,
  50. speed = Math.round(count / div_by),
  51. $display = $('.count3'),
  52. run_count = 1,
  53. int_speed = 24;
  54.  
  55. var int = setInterval(function() {
  56. if(run_count < div_by){
  57. $display.text(speed * run_count);
  58. run_count++;
  59. } else if(parseInt($display.text()) < count) {
  60. var curr_count = parseInt($display.text()) + 1;
  61. $display.text(curr_count);
  62. } else {
  63. clearInterval(int);
  64. }
  65. }, int_speed);
  66. }
  67.  
  68. countUp3(328);
  69.  
  70. function countUp4(count)
  71. {
  72. var div_by = 100,
  73. speed = Math.round(count / div_by),
  74. $display = $('.count4'),
  75. run_count = 1,
  76. int_speed = 24;
  77.  
  78. var int = setInterval(function() {
  79. if(run_count < div_by){
  80. $display.text(speed * run_count);
  81. run_count++;
  82. } else if(parseInt($display.text()) < count) {
  83. var curr_count = parseInt($display.text()) + 1;
  84. $display.text(curr_count);
  85. } else {
  86. clearInterval(int);
  87. }
  88. }, int_speed);
  89. }
  90.  
  91. countUp4(10328);
Advertisement
Add Comment
Please, Sign In to add comment