From dd63511130e57ebdc79451a1ebecbb833bf45168 Mon Sep 17 00:00:00 2001 From: Jollus88 Date: Wed, 29 Apr 2020 19:24:01 +1000 Subject: [PATCH] adding delay after user input to prevent jank as chart refreshes --- js/translations.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/translations.js b/js/translations.js index 0930173..dcc1b1f 100644 --- a/js/translations.js +++ b/js/translations.js @@ -52,6 +52,15 @@ i18next }); // init set content $(document).ready(initialize); - $(document).on('input', updateContent); + + let delayTimer; + $(document).on('input', function() { + // adding short delay after input to help mitigate potential lag after keystrokes + clearTimeout(delayTimer); + delayTimer = setTimeout(function() { + updateContent(); + }, 1000); + }); + $('input[type = radio]').on('change', updateContent); });