Improves drag and drop event handling
Refactors drag and drop logic for better event handling and code clarity. - Moves drag styling to CSS class for cleaner code. - Emits a 'drag:convert-from-allday' event to handle the conversion of all-day events back to day events. - Adds logging for debugging purposes.
This commit is contained in:
parent
7e45293128
commit
b95a516806
3 changed files with 42 additions and 29 deletions
|
|
@ -107,12 +107,6 @@ export class DragDropManager {
|
|||
originalElement: draggedElement,
|
||||
headerRenderer
|
||||
});
|
||||
|
||||
// Hide drag clone completely
|
||||
const dragClone = document.querySelector(`swp-event[data-event-id="clone-${this.draggedEventId}"]`);
|
||||
if (dragClone) {
|
||||
(dragClone as HTMLElement).style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -131,21 +125,13 @@ export class DragDropManager {
|
|||
}
|
||||
});
|
||||
|
||||
// Listen for header mouseleave events (remove all-day event, let clone take over)
|
||||
// Listen for header mouseleave events (convert from all-day back to day)
|
||||
this.eventBus.on('header:mouseleave', (event) => {
|
||||
// Check if we're dragging ANY event
|
||||
if (this.draggedEventId) {
|
||||
// Find and remove all-day event specifically in the container
|
||||
const allDayEvent = document.querySelector(`swp-allday-container swp-allday-event[data-event-id="${this.draggedEventId}"]`);
|
||||
if (allDayEvent) {
|
||||
allDayEvent.remove();
|
||||
}
|
||||
|
||||
// Show drag clone again
|
||||
const dragClone = document.querySelector(`swp-event[data-event-id="clone-${this.draggedEventId}"]`);
|
||||
if (dragClone) {
|
||||
(dragClone as HTMLElement).style.display = 'block';
|
||||
}
|
||||
this.eventBus.emit('drag:convert-from-allday', {
|
||||
draggedEventId: this.draggedEventId
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -288,6 +274,13 @@ export class DragDropManager {
|
|||
// Use consolidated position calculation
|
||||
const positionData = this.calculateDragPosition(finalPosition);
|
||||
|
||||
console.log('🎯 DragDropManager: Emitting drag:end', {
|
||||
eventId: eventId,
|
||||
finalColumn: positionData.column,
|
||||
finalY: positionData.snappedY,
|
||||
isDragStarted: isDragStarted
|
||||
});
|
||||
|
||||
this.eventBus.emit('drag:end', {
|
||||
eventId: eventId,
|
||||
finalPosition,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue