diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2022-10-26 10:05:04 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2022-11-09 21:40:27 +0000 |
| commit | 7982002a644328164bf0f77bf489876ad012e90d (patch) | |
| tree | 496e54d8dc6e6bd2c0fcd08f8f9a377c1021f830 /emccpre.js | |
| parent | c5a2446fae603a480de58b912fa349549bd9f247 (diff) | |
| download | puzzles-7982002a644328164bf0f77bf489876ad012e90d.zip puzzles-7982002a644328164bf0f77bf489876ad012e90d.tar.gz puzzles-7982002a644328164bf0f77bf489876ad012e90d.tar.bz2 puzzles-7982002a644328164bf0f77bf489876ad012e90d.tar.xz | |
js: Switch to window.requestAnimationFrame() for timing
This is an API specifically designed for the purposes of timing
animations. Unlike setInterval, it tries to synchronise with the screen
refresh rate. It naturally passes us timing information, saving the
need to construct a Date object every frame. It has the nice feature
that browsers (at least Firefox 91) will call it less frequently when
the puzzle page isn't visible, which saves CPU time in puzzles that run
a timer continuously.
Diffstat (limited to 'emccpre.js')
| -rw-r--r-- | emccpre.js | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -90,8 +90,8 @@ var midpoint_test_str = "ABCDEFGHIKLMNOPRSTUVWXYZ0123456789"; var midpoint_cache = []; // Variables used by js_activate_timer() and js_deactivate_timer(). -var timer = null; -var timer_reference_date; +var timer_active = false; +var timer_reference; // void timer_callback(double tplus); // |