File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -286,6 +286,33 @@ const HTML_TEMPLATE = `<!doctype html>
286286 window.addEventListener('resize', () => {
287287 fitAddon.fit();
288288 });
289+
290+ // Handle mobile keyboard showing/hiding using visualViewport API
291+ if (window.visualViewport) {
292+ const terminalContent = document.querySelector('.terminal-content');
293+ const terminalWindow = document.querySelector('.terminal-window');
294+ const originalHeight = terminalContent.style.height;
295+ const body = document.body;
296+
297+ window.visualViewport.addEventListener('resize', () => {
298+ const keyboardHeight = window.innerHeight - window.visualViewport.height;
299+ if (keyboardHeight > 100) {
300+ body.style.padding = '0';
301+ body.style.alignItems = 'flex-start';
302+ terminalWindow.style.borderRadius = '0';
303+ terminalWindow.style.maxWidth = '100%';
304+ terminalContent.style.height = (window.visualViewport.height - 60) + 'px';
305+ window.scrollTo(0, 0);
306+ } else {
307+ body.style.padding = '40px 20px';
308+ body.style.alignItems = 'center';
309+ terminalWindow.style.borderRadius = '12px';
310+ terminalWindow.style.maxWidth = '1000px';
311+ terminalContent.style.height = originalHeight || '600px';
312+ }
313+ fitAddon.fit();
314+ });
315+ }
289316 </script>
290317 </body>
291318</html>` ;
You can’t perform that action at this time.
0 commit comments