diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-06-25 14:56:59 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-06-25 14:56:59 +0200 |
commit | 4acd53db27b652834ed096307b3561b880ebbd72 (patch) | |
tree | 566bc97b6a47f48c4101f129ead55c37a56a4e67 | |
parent | 36097212c07ba98c9ecade40195c677211010e46 (diff) |
Resize event debouncing
-rw-r--r-- | game.js | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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); +}); |