From: Shuanglei Tao Date: Sat, 10 Jun 2017 00:22:06 +0000 (+0800) Subject: Ony fire resize event when it ends X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=4cbc7748cfc11071120ca5e7698fa0e2a4962a52;p=ttyd.git Ony fire resize event when it ends --- 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
- +