code_junkie

Is there a more accurate way to create a Javascript timer than setTimeout?

Nov 11th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. calculate_remaining_time
  2. if remaining_time > 20ms // maybe as much as 50
  3. re-queue the handler for 10ms time
  4. else
  5. {
  6. while( remaining_time > 0 ) calculate_remaining_time;
  7. do_your_thing();
  8. re-queue the handler for 100ms before the next required time
  9. }
Add Comment
Please, Sign In to add comment