Skip to content

Commit 2c4f451

Browse files
done
1 parent dddd072 commit 2c4f451

2 files changed

Lines changed: 30 additions & 10 deletions

File tree

script.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -441,34 +441,52 @@ const editorContainer = document.getElementById('editor-container');
441441

442442
let isResizing = false;
443443

444-
resizer.addEventListener('mousedown', (e) => {
444+
resizer.addEventListener('mousedown', startResizing);
445+
resizer.addEventListener('touchstart', (e) => {
446+
startResizing(e.touches[0]);
447+
}, { passive: false });
448+
449+
function startResizing(e) {
445450
isResizing = true;
446451
resizer.classList.add('resizing');
447452
document.body.style.cursor = 'row-resize';
448-
document.body.style.userSelect = 'none'; // Prevent text selection
449-
});
453+
document.body.style.userSelect = 'none';
454+
}
450455

451-
document.addEventListener('mousemove', (e) => {
456+
function handleMouseMove(e) {
452457
if (!isResizing) return;
453458

454-
// Calculate new height
455-
// Total height - mouse Y position
456459
const containerRect = document.querySelector('.main-editor').getBoundingClientRect();
457-
const newHeight = containerRect.bottom - e.clientY;
460+
const clientY = e.clientY || (e.touches && e.touches[0].clientY);
461+
462+
if (!clientY) return;
463+
464+
const newHeight = containerRect.bottom - clientY;
458465

459466
if (newHeight >= 100 && newHeight <= containerRect.height - 100) {
460467
terminalContainer.style.height = `${newHeight}px`;
461468
}
462-
});
469+
}
463470

464-
document.addEventListener('mouseup', () => {
471+
document.addEventListener('mousemove', handleMouseMove);
472+
document.addEventListener('touchmove', (e) => {
473+
if (isResizing) {
474+
handleMouseMove(e.touches[0]);
475+
if (e.cancelable) e.preventDefault(); // Prevent scrolling while resizing
476+
}
477+
}, { passive: false });
478+
479+
function stopResizing() {
465480
if (isResizing) {
466481
isResizing = false;
467482
resizer.classList.remove('resizing');
468483
document.body.style.cursor = '';
469484
document.body.style.userSelect = '';
470485
}
471-
});
486+
}
487+
488+
document.addEventListener('mouseup', stopResizing);
489+
document.addEventListener('touchend', stopResizing);
472490
// Mobile Sidebar Logic
473491
const sidebarToggleBtn = document.getElementById('sidebar-toggle');
474492
const sidebar = document.querySelector('.sidebar');

style.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ pre[class*="language-"] {
431431
justify-content: center;
432432
flex-shrink: 0;
433433
transition: all 0.2s;
434+
touch-action: none;
435+
/* Critical for mobile touch resizing */
434436
}
435437

436438
.resizer:hover,

0 commit comments

Comments
 (0)