mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-22 11:54:19 +01:00
Ony fire resize event when it ends
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user