js: Reinstate a missing variable declaration

... and then decide there was no excuse for renaming the variable, so
now it has the same name it had before I started using
Window.requestAnimationFrame().
This commit is contained in:
Ben Harris
2022-11-09 23:44:26 +00:00
parent 7982002a64
commit f7957d3aa0
2 changed files with 7 additions and 6 deletions

View File

@ -200,16 +200,16 @@ mergeInto(LibraryManager.library, {
if (!timer_active) {
timer_reference = performance.now();
var frame = function(now) {
current_timer = null;
timer = null;
timer_callback((now - timer_reference) / 1000.0);
/* The callback may have deactivated the timer. */
if (timer_active) {
timer_reference = now;
current_timer = window.requestAnimationFrame(frame);
timer = window.requestAnimationFrame(frame);
}
}
timer_active = true;
current_timer = window.requestAnimationFrame(frame);
timer = window.requestAnimationFrame(frame);
}
},
@ -221,9 +221,9 @@ mergeInto(LibraryManager.library, {
js_deactivate_timer: function() {
if (timer_active) {
timer_active = false;
if (current_timer !== null) {
window.cancelAnimationFrame(current_timer);
current_timer = null;
if (timer !== null) {
window.cancelAnimationFrame(timer);
timer = null;
}
}
},

View File

@ -90,6 +90,7 @@ var midpoint_test_str = "ABCDEFGHIKLMNOPRSTUVWXYZ0123456789";
var midpoint_cache = [];
// Variables used by js_activate_timer() and js_deactivate_timer().
var timer = null;
var timer_active = false;
var timer_reference;