Skip to content

Commit

Permalink
Add dyn window resizing with debounce.
Browse files Browse the repository at this point in the history
  • Loading branch information
leihaiyong committed Jan 12, 2022
1 parent dc1a184 commit e806bd0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions public/template/term.template
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
})
fitAddon.fit();
term.focus();

function debounce(f, timeout){
let t;
return (...args) => {
clearTimeout(t);
t = setTimeout(() => { f.apply(this, args); }, timeout);
};
};

window.addEventListener('resize', debounce(() => {
fitAddon.fit();
}, 250));
</script>
</body>
</html>

0 comments on commit e806bd0

Please sign in to comment.