diff --git a/src/managers/DragDropManager.ts b/src/managers/DragDropManager.ts index 7ea7496..347f15f 100644 --- a/src/managers/DragDropManager.ts +++ b/src/managers/DragDropManager.ts @@ -298,19 +298,6 @@ 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 @@ -478,7 +465,7 @@ export class DragDropManager { /** * Smooth drag animation using requestAnimationFrame - * Only interpolates currentY - events are emitted from continueDrag() + * Emits drag:move events with current draggedClone reference on each frame */ private animateDrag(): void { if (!this.isDragStarted || !this.draggedClone || !this.targetColumn) { @@ -493,10 +480,34 @@ export class DragDropManager { // Update if difference is significant if (Math.abs(diff) > 0.5) { this.currentY += step; + + // Emit drag:move event with current draggedClone reference + const dragMovePayload: DragMoveEventPayload = { + draggedElement: this.draggedElement!, + draggedClone: this.draggedClone, // Always uses current reference + 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; + + // Emit final 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 = null; } }