Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- viewbox=document.getElementsByTagName("pre")[0];
- var viewcount=new Object({});
- var countUp; // declare for scope
- var tanh_animation=0;
- viewcount.old=0;
- viewcount.displayed=0;
- viewcount.new=1000;
- function increaseViewCount() {
- viewcount.displayed=Math.round( viewcount.old + (viewcount.new-viewcount.old)*Math.tanh(tanh_animation/10) );
- tanh_animation++;
- viewbox.innerHTML=viewcount.displayed;
- if ( Math.abs(viewcount.displayed-viewcount.new) < 0.5 ) {
- clearInterval(countUp);
- viewbox.innerHTML=viewcount.new;
- viewcount.old=viewcount.new; // remember for next time
- tanh_animation=0; // reset
- };
- };
- function countTo(number){
- viewcount.new=number;
- countUp=setInterval(increaseViewCount,50);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement