Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Counter(ms,accuracy){
- var duration = ms;
- var progress = 0;
- var accuracy = accuracy || 100; //100ms update default
- var interval = setInterval(tick(), accuracy);
- function tick(){
- progress += accuracy;
- console.log(progress);
- if (progress >= duration){
- window.clearInterval(interval);
- console.log("Timer finished");
- }
- }
- }
- var x = new Counter(20000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement