diff --git a/src/managers/DragDropManager.ts b/src/managers/DragDropManager.ts index e6ba9f7..6076874 100644 --- a/src/managers/DragDropManager.ts +++ b/src/managers/DragDropManager.ts @@ -44,7 +44,7 @@ export class DragDropManager { // Scroll compensation private scrollableContent: HTMLElement | null = null; - private accumulatedScrollDelta = 0; // Total scroll movement since drag start + private scrollDeltaY = 0; // Current scroll delta to apply in continueDrag private lastScrollTop = 0; // Last scroll position for delta calculation private isScrollCompensating = false; // Track if scroll compensation is active private hasScrolledDuringDrag = false; // Track if we have scrolled during this drag operation @@ -270,12 +270,10 @@ export class DragDropManager { if (column) { // Calculate raw Y position relative to column (accounting for mouse offset) const columnRect = column.boundingClientRect; - let eventTopY = currentPosition.y - columnRect.top - this.mouseOffset.y; - // Kompenser for akkumuleret scroll bevægelse - if (this.accumulatedScrollDelta !== 0) { - eventTopY += this.accumulatedScrollDelta; - } + // Beregn position fra mus + scroll delta kompensation + const adjustedMouseY = currentPosition.y + this.scrollDeltaY; + const eventTopY = adjustedMouseY - columnRect.top - this.mouseOffset.y; this.targetY = Math.max(0, eventTopY); this.targetColumn = column; @@ -464,7 +462,7 @@ export class DragDropManager { } /** - * Handle scroll during drag - track accumulated scroll delta + * Handle scroll during drag - update scrollDeltaY and call continueDrag */ private handleScroll(): void { if (!this.isDragStarted || !this.draggedClone || !this.scrollableContent || !this.isScrollCompensating) return; @@ -472,15 +470,18 @@ export class DragDropManager { const currentScrollTop = this.scrollableContent.scrollTop; const scrollDelta = currentScrollTop - this.lastScrollTop; - // Akkumuler scroll bevægelse (continueDrag vil bruge denne) - this.accumulatedScrollDelta += scrollDelta; + // Gem scroll delta for continueDrag + this.scrollDeltaY += scrollDelta; this.lastScrollTop = currentScrollTop; + // Kald continueDrag med nuværende mus position + this.continueDrag(this.currentMousePosition); + console.log('📜 DragDropManager: Scroll compensation', { currentScrollTop, lastScrollTop: this.lastScrollTop - scrollDelta, scrollDelta, - accumulatedScrollDelta: this.accumulatedScrollDelta + scrollDeltaY: this.scrollDeltaY }); } @@ -504,7 +505,7 @@ export class DragDropManager { this.currentColumn = null; this.isDragStarted = false; this.hasScrolledDuringDrag = false; - this.accumulatedScrollDelta = 0; + this.scrollDeltaY = 0; this.lastScrollTop = 0; }