From 4acd53db27b652834ed096307b3561b880ebbd72 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 25 Jun 2018 14:56:59 +0200 Subject: Resize event debouncing --- game.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); +}); -- cgit v1.2.3-70-g09d2