From 4cbc7748cfc11071120ca5e7698fa0e2a4962a52 Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Sat, 10 Jun 2017 08:22:06 +0800 Subject: [PATCH] Ony fire resize event when it ends --- html/js/app.js | 10 +++++++--- src/index.html | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/html/js/app.js b/html/js/app.js index 2b5a0fb..47a732c 100644 --- a/html/js/app.js +++ b/html/js/app.js @@ -1,6 +1,6 @@ (function() { var terminalContainer = document.getElementById('terminal-container'), - httpsEnabled = window.location.protocol == "https:", + httpsEnabled = window.location.protocol === "https:", url = (httpsEnabled ? 'wss://' : 'ws://') + window.location.host + window.location.pathname + 'ws', authToken = (typeof tty_auth_token !== 'undefined') ? tty_auth_token : null, protocols = ["tty"], @@ -43,8 +43,12 @@ }); term.on('open', function() { - window.addEventListener('resize', function(event) { - term.fit(); + // https://stackoverflow.com/a/27923937/1727928 + window.addEventListener('resize', function() { + clearTimeout(window.resizedFinished); + window.resizedFinished = setTimeout(function () { + term.fit(); + }, 250); }); window.addEventListener('beforeunload', unloadCallback); term.fit(); diff --git a/src/index.html b/src/index.html index 65331d7..bbf1803 100644 --- a/src/index.html +++ b/src/index.html @@ -17,6 +17,6 @@ break;case"mouseup":e=3;break;case"DOMMouseScroll":e=t.detail<0?64:65;break;case
- + -- 2.43.4