@@ -358,6 +358,51 @@ function getRank(lvl) {
358358const consoleContainer = document . getElementById ( 'matrix-console-container' ) ;
359359const consoleOutput = document . getElementById ( 'matrix-console-output' ) ;
360360
361+ const dragContainer = document . getElementById ( 'matrix-console-container' ) ;
362+ const dragHeader = dragContainer . querySelector ( '.bg-green-500\\/10' ) ; // Selects the header bar
363+
364+ let isDragging = false ;
365+ let offsetLeft = 0 ;
366+ let offsetTop = 0 ;
367+
368+ dragHeader . addEventListener ( 'mousedown' , ( e ) => {
369+ // Prevent dragging when clicking the minimize/close buttons
370+ if ( e . target . tagName === 'BUTTON' ) return ;
371+
372+ isDragging = true ;
373+
374+ // Calculate where the mouse is relative to the top-left of the console
375+ const rect = dragContainer . getBoundingClientRect ( ) ;
376+ offsetLeft = e . clientX - rect . left ;
377+ offsetTop = e . clientY - rect . top ;
378+
379+ // Change cursor to indicate moving
380+ dragHeader . style . cursor = 'grabbing' ;
381+ } ) ;
382+
383+ document . addEventListener ( 'mousemove' , ( e ) => {
384+ if ( ! isDragging ) return ;
385+
386+ // Calculate new position
387+ let x = e . clientX - offsetLeft ;
388+ let y = e . clientY - offsetTop ;
389+
390+ // Boundary Check (Optional: keeps it inside the screen)
391+ x = Math . max ( 0 , Math . min ( x , window . innerWidth - dragContainer . offsetWidth ) ) ;
392+ y = Math . max ( 0 , Math . min ( y , window . innerHeight - dragContainer . offsetHeight ) ) ;
393+
394+ // Apply position and remove Tailwind's 'bottom' and 'right' so they don't fight the 'top'/'left'
395+ dragContainer . style . bottom = 'auto' ;
396+ dragContainer . style . right = 'auto' ;
397+ dragContainer . style . left = `${ x } px` ;
398+ dragContainer . style . top = `${ y } px` ;
399+ } ) ;
400+
401+ document . addEventListener ( 'mouseup' , ( ) => {
402+ isDragging = false ;
403+ dragHeader . style . cursor = 'grab' ;
404+ } ) ;
405+
361406function minimizeConsole ( ) {
362407 // Toggles the height of the output area
363408 if ( consoleOutput . style . display === 'none' ) {
0 commit comments