@@ -441,34 +441,52 @@ const editorContainer = document.getElementById('editor-container');
441441
442442let 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
473491const sidebarToggleBtn = document . getElementById ( 'sidebar-toggle' ) ;
474492const sidebar = document . querySelector ( '.sidebar' ) ;
0 commit comments