Jquery Plugin for animating numbers -
i making ajax call server , updating stats. want plugin animates numbers.
e.g. initial value = 65 value after ajax call = 98
in span of 2 seconds, value displayed increases 65 98 , user able see - digital speedometers or tachometers.
my search has not led me find plugin this. know of such plugin?
it doesnt have duration, it's kinda close. i'm not sure how integrate duration @ moment, , had throw rather quickly.
(function($) { $.fn.animatenumber = function(to) { var $ele = $(this), num = parseint($ele.html()), = > num, num_interval = math.abs(num - to) / 90; var loop = function() { num = math.floor(up ? num+num_interval: num-num_interval); if ( (up && num > to) || (!up && num < to) ) { num = to; clearinterval(animation) } $ele.html(num); } var animation = setinterval(loop, 5); } })(jquery) var $counter = $("#counter"); $counter.animatenumber(800); <span id="counter">100</span>
Comments
Post a Comment