Ony fire resize event when it ends

This commit is contained in:
Shuanglei Tao
2017-06-10 08:22:06 +08:00
parent 055463542f
commit 4cbc7748cf
2 changed files with 8 additions and 4 deletions

View File

@@ -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();