@@ -252,6 +252,95 @@ <h2 class="info-header">Drop Information</h2>
252252 const pathDisplay = document . getElementById ( 'current-path' ) ;
253253 const folderNodes = document . querySelectorAll ( '.folder-dropzone' ) ;
254254
255+ // Add debug coordinate overlay
256+ let debugOverlay = null ;
257+
258+ function createDebugOverlay ( ) {
259+ if ( debugOverlay ) return ;
260+
261+ debugOverlay = document . createElement ( 'div' ) ;
262+ debugOverlay . style . cssText = `
263+ position: fixed;
264+ top: 10px;
265+ right: 10px;
266+ background: rgba(0, 0, 0, 0.8);
267+ color: white;
268+ padding: 10px;
269+ border-radius: 5px;
270+ font-family: monospace;
271+ font-size: 12px;
272+ z-index: 10000;
273+ pointer-events: none;
274+ white-space: pre-line;
275+ ` ;
276+ document . body . appendChild ( debugOverlay ) ;
277+ }
278+
279+ function updateDebugOverlay ( info ) {
280+ if ( ! debugOverlay ) createDebugOverlay ( ) ;
281+ debugOverlay . textContent = info ;
282+ }
283+
284+ // Track mouse position and other debug info
285+ let mouseInfo = { x : 0 , y : 0 } ;
286+ let windowInfo = { width : window . innerWidth , height : window . innerHeight } ;
287+
288+ document . addEventListener ( 'mousemove' , ( e ) => {
289+ mouseInfo . x = e . clientX ;
290+ mouseInfo . y = e . clientY ;
291+
292+ const debugInfo = `Mouse: ${ e . clientX } , ${ e . clientY }
293+ Page: ${ e . pageX } , ${ e . pageY }
294+ Screen: ${ e . screenX } , ${ e . screenY }
295+ Window: ${ windowInfo . width } x${ windowInfo . height }
296+ Viewport offset: ${ window . pageXOffset } , ${ window . pageYOffset } ` ;
297+
298+ updateDebugOverlay ( debugInfo ) ;
299+ } ) ;
300+
301+ // Add drag event listeners to show coordinates during drag
302+ document . addEventListener ( 'dragover' , ( e ) => {
303+ e . preventDefault ( ) ;
304+ const debugInfo = `[DRAGOVER]
305+ Mouse: ${ e . clientX } , ${ e . clientY }
306+ Page: ${ e . pageX } , ${ e . pageY }
307+ Screen: ${ e . screenX } , ${ e . screenY }
308+ Window: ${ windowInfo . width } x${ windowInfo . height }
309+ Target: ${ e . target . tagName } ${ e . target . className } ` ;
310+
311+ updateDebugOverlay ( debugInfo ) ;
312+ } ) ;
313+
314+ document . addEventListener ( 'drop' , ( e ) => {
315+ e . preventDefault ( ) ;
316+ const rect = e . target . getBoundingClientRect ( ) ;
317+ const debugInfo = `[DROP EVENT]
318+ Client: ${ e . clientX } , ${ e . clientY }
319+ Page: ${ e . pageX } , ${ e . pageY }
320+ Screen: ${ e . screenX } , ${ e . screenY }
321+ Target rect: ${ rect . left } , ${ rect . top } , ${ rect . width } x${ rect . height }
322+ Relative to target: ${ e . clientX - rect . left } , ${ e . clientY - rect . top }
323+ Window: ${ windowInfo . width } x${ windowInfo . height } ` ;
324+
325+ updateDebugOverlay ( debugInfo ) ;
326+ console . log ( 'Drop event debug info:' , {
327+ clientX : e . clientX ,
328+ clientY : e . clientY ,
329+ pageX : e . pageX ,
330+ pageY : e . pageY ,
331+ screenX : e . screenX ,
332+ screenY : e . screenY ,
333+ targetRect : rect ,
334+ relativeX : e . clientX - rect . left ,
335+ relativeY : e . clientY - rect . top
336+ } ) ;
337+ } ) ;
338+
339+ window . addEventListener ( 'resize' , ( ) => {
340+ windowInfo . width = window . innerWidth ;
341+ windowInfo . height = window . innerHeight ;
342+ } ) ;
343+
255344 // Update path display when clicking folders
256345 folderNodes . forEach ( folder => {
257346 folder . addEventListener ( 'click' , ( e ) => {
@@ -266,43 +355,70 @@ <h2 class="info-header">Drop Information</h2>
266355
267356 // Listen for the file drop event from Wails
268357 wails . Events . On ( "frontend:FileDropInfo" , ( eventData ) => {
269- console . log ( "File drop detected:" , eventData ) ;
358+ console . log ( "=============== Frontend: File Drop Debug Info ===============" ) ;
359+ console . log ( "Full event data:" , eventData ) ;
270360
271361 const { files, targetID, targetClasses, dropX, dropY, attributes } = eventData . data [ 0 ] ;
272362
363+ console . log ( "Extracted data:" , {
364+ files,
365+ targetID,
366+ targetClasses,
367+ dropX,
368+ dropY,
369+ attributes
370+ } ) ;
371+
273372 // Get additional folder information from the attributes
274373 const folderPath = attributes ? attributes [ 'data-path' ] : 'Unknown path' ;
275374 const folderName = attributes ? attributes [ 'data-folder-name' ] : 'Unknown folder' ;
276375
277- let message = `Files dropped on folder: ${ folderName } \n` ;
376+ let message = `=============== FILE DROP DEBUG REPORT ===============\n` ;
377+ message += `Files dropped on folder: ${ folderName } \n` ;
278378 message += `Target path: ${ folderPath } \n` ;
279379 message += `Element ID: ${ targetID || 'N/A' } \n` ;
280- message += `Element Classes: ${ targetClasses && targetClasses . length > 0 ? targetClasses . join ( ', ' ) : 'N/A' } \n\n` ;
380+ message += `Element Classes: ${ targetClasses && targetClasses . length > 0 ? targetClasses . join ( ', ' ) : 'N/A' } \n` ;
381+ message += `\n=== COORDINATE DEBUG INFO ===\n` ;
382+ message += `Drop Coordinates from Wails: X=${ dropX . toFixed ( 2 ) } , Y=${ dropY . toFixed ( 2 ) } \n` ;
383+ message += `Current Mouse Position: X=${ mouseInfo . x } , Y=${ mouseInfo . y } \n` ;
384+ message += `Window Size: ${ windowInfo . width } x${ windowInfo . height } \n` ;
385+
386+ // Get the target element to show its position
387+ const targetElement = document . querySelector ( `[data-folder-id="${ targetID } "]` ) ;
388+ if ( targetElement ) {
389+ const rect = targetElement . getBoundingClientRect ( ) ;
390+ message += `Target Element Position:\n` ;
391+ message += ` - Bounding rect: left=${ rect . left } , top=${ rect . top } , right=${ rect . right } , bottom=${ rect . bottom } \n` ;
392+ message += ` - Size: ${ rect . width } x${ rect . height } \n` ;
393+ message += ` - Center: ${ rect . left + rect . width / 2 } , ${ rect . top + rect . height / 2 } \n` ;
394+ message += ` - Drop relative to element: X=${ dropX - rect . left } , Y=${ dropY - rect . top } \n` ;
395+ }
281396
282- // Display all attributes from the element
397+ message += `\n=== ELEMENT ATTRIBUTES ===\n` ;
283398 if ( attributes && Object . keys ( attributes ) . length > 0 ) {
284- message += "Element Attributes:\n" ;
285399 Object . entries ( attributes ) . forEach ( ( [ key , value ] ) => {
286400 message += ` ${ key } : "${ value } "\n` ;
287401 } ) ;
288- message += "\n" ;
402+ } else {
403+ message += " No attributes found\n" ;
289404 }
290405
291- // List all dropped files
292- message += "Dropped Files:\n" ;
293- files . forEach ( file => {
294- message += ` → ${ file } \n` ;
406+ message += `\n=== DROPPED FILES ===\n` ;
407+ files . forEach ( ( file , index ) => {
408+ message += ` ${ index + 1 } . ${ file } \n` ;
295409 } ) ;
296410
297- message += `\nDrop Coordinates: X=${ dropX . toFixed ( 2 ) } , Y=${ dropY . toFixed ( 2 ) } ` ;
298-
299- // Show a simulated upload message
300- message += "\n\nSimulating upload to " + folderPath + "..." ;
411+ message += `\n=== SIMULATION ===\n` ;
412+ message += `Simulating upload to ${ folderPath } ...\n` ;
413+ message += `===========================================` ;
301414
302415 outputDiv . textContent = message ;
416+
417+ console . log ( "=============== End Frontend Debug ===============" ) ;
303418 } ) ;
304419
305- console . log ( "File Tree Drag-and-Drop example initialized." ) ;
420+ console . log ( "File Tree Drag-and-Drop example initialized with enhanced debugging." ) ;
421+ createDebugOverlay ( ) ;
306422 </ script >
307423</ body >
308424</ html >
0 commit comments