aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-06-25 14:56:59 +0200
committerTom Smeding <tom.smeding@gmail.com>2018-06-25 14:56:59 +0200
commit4acd53db27b652834ed096307b3561b880ebbd72 (patch)
tree566bc97b6a47f48c4101f129ead55c37a56a4e67
parent36097212c07ba98c9ecade40195c677211010e46 (diff)
Resize event debouncing
-rw-r--r--game.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/game.js b/game.js
index fa8ff23..1d06a2e 100644
--- a/game.js
+++ b/game.js
@@ -277,4 +277,11 @@ window.addEventListener("load", function() {
openGame();
});
-window.addEventListener("resize", resizeHandler);
+var resizeDebounceTimeout = null;
+window.addEventListener("resize", function() {
+ if (resizeDebounceTimeout != null) return;
+ resizeDebounceTimeout = setTimeout(function() {
+ resizeDebounceTimeout = null;
+ resizeHandler();
+ }, 50);
+});