Refactors all-day event conversion to timed events
Streamlines the conversion of all-day events to timed events during drag and drop operations. This change improves the event rendering process by ensuring proper handling of element replacement and position updates. Removes redundant code and simplifies the logic for updating the dragged clone.
This commit is contained in:
parent
0a3d274164
commit
9b073a15b7
3 changed files with 40 additions and 63 deletions
|
|
@ -226,6 +226,7 @@ export class DragDropManager {
|
|||
|
||||
// Continue drag if started
|
||||
if (this.isDragStarted && this.draggedElement && this.draggedClone) {
|
||||
console.log("Continue drag if started", this.draggedClone);
|
||||
this.continueDrag(currentPosition);
|
||||
this.detectAndEmitColumnChange(currentPosition);
|
||||
}
|
||||
|
|
@ -280,9 +281,10 @@ export class DragDropManager {
|
|||
* Continue drag movement - update position and auto-scroll
|
||||
*/
|
||||
private continueDrag(currentPosition: MousePosition): void {
|
||||
if (!this.draggedElement!.hasAttribute("data-allday")) {
|
||||
if (!this.draggedClone!.hasAttribute("data-allday")) {
|
||||
// Calculate raw position from mouse (no snapping)
|
||||
const column = ColumnDetectionUtils.getColumnBounds(currentPosition);
|
||||
console.log("continueDrag");
|
||||
|
||||
if (column) {
|
||||
// Calculate raw Y position relative to column (accounting for mouse offset)
|
||||
|
|
@ -296,11 +298,26 @@ export class DragDropManager {
|
|||
this.currentY = parseFloat(this.draggedClone!.style.top) || 0;
|
||||
this.animateDrag();
|
||||
}
|
||||
|
||||
// Emit drag:move event with current draggedClone reference
|
||||
if (this.draggedClone) {
|
||||
const dragMovePayload: DragMoveEventPayload = {
|
||||
draggedElement: this.draggedElement!,
|
||||
draggedClone: this.draggedClone,
|
||||
mousePosition: currentPosition,
|
||||
snappedY: this.currentY,
|
||||
columnBounds: column,
|
||||
mouseOffset: this.mouseOffset
|
||||
};
|
||||
this.eventBus.emit('drag:move', dragMovePayload);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for auto-scroll
|
||||
this.checkAutoScroll(currentPosition);
|
||||
}
|
||||
else
|
||||
console.log("hasAttribute(data-allday)");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -461,6 +478,7 @@ export class DragDropManager {
|
|||
|
||||
/**
|
||||
* Smooth drag animation using requestAnimationFrame
|
||||
* Only interpolates currentY - events are emitted from continueDrag()
|
||||
*/
|
||||
private animateDrag(): void {
|
||||
if (!this.isDragStarted || !this.draggedClone || !this.targetColumn) {
|
||||
|
|
@ -475,33 +493,10 @@ export class DragDropManager {
|
|||
// Update if difference is significant
|
||||
if (Math.abs(diff) > 0.5) {
|
||||
this.currentY += step;
|
||||
|
||||
// Emit drag move event with interpolated position
|
||||
const dragMovePayload: DragMoveEventPayload = {
|
||||
draggedElement: this.draggedElement!,
|
||||
draggedClone: this.draggedClone,
|
||||
mousePosition: this.lastMousePosition,
|
||||
snappedY: this.currentY,
|
||||
columnBounds: this.targetColumn,
|
||||
mouseOffset: this.mouseOffset
|
||||
};
|
||||
this.eventBus.emit('drag:move', dragMovePayload);
|
||||
|
||||
this.dragAnimationId = requestAnimationFrame(() => this.animateDrag());
|
||||
} else {
|
||||
// Close enough - snap to target
|
||||
this.currentY = this.targetY;
|
||||
|
||||
const dragMovePayload: DragMoveEventPayload = {
|
||||
draggedElement: this.draggedElement!,
|
||||
draggedClone: this.draggedClone,
|
||||
mousePosition: this.lastMousePosition,
|
||||
snappedY: this.currentY,
|
||||
columnBounds: this.targetColumn,
|
||||
mouseOffset: this.mouseOffset
|
||||
};
|
||||
this.eventBus.emit('drag:move', dragMovePayload);
|
||||
|
||||
this.dragAnimationId = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -649,6 +644,7 @@ export class DragDropManager {
|
|||
// Delegate pattern - allows AllDayManager to replace the clone
|
||||
replaceClone: (newClone: HTMLElement) => {
|
||||
this.draggedClone = newClone;
|
||||
this.dragAnimationId === null;
|
||||
}
|
||||
};
|
||||
this.eventBus.emit('drag:mouseenter-header', dragMouseEnterPayload);
|
||||
|
|
@ -690,6 +686,9 @@ export class DragDropManager {
|
|||
// Delegate pattern - allows EventRenderer to replace the clone
|
||||
replaceClone: (newClone: HTMLElement) => {
|
||||
this.draggedClone = newClone;
|
||||
this.dragAnimationId === null;
|
||||
this.stopDragAnimation();
|
||||
console.log("replacing clone with", newClone)
|
||||
}
|
||||
};
|
||||
this.eventBus.emit('drag:mouseenter-column', dragMouseEnterPayload);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue