From 954df5626d560501c8037e6409081e2c24d9ac00 Mon Sep 17 00:00:00 2001 From: minlovehua <321512939@qq.com> Date: Fri, 7 Apr 2023 18:10:46 +0800 Subject: [PATCH 1/3] fix(gantt): the fast right (left) dragging start (end) time, the width of bar is wrong #INFR-7111 --- packages/gantt/src/components/bar/bar-drag.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/gantt/src/components/bar/bar-drag.ts b/packages/gantt/src/components/bar/bar-drag.ts index d4f5ef1d..be2e1994 100644 --- a/packages/gantt/src/components/bar/bar-drag.ts +++ b/packages/gantt/src/components/bar/bar-drag.ts @@ -74,6 +74,8 @@ export class GanttBarDrag implements OnDestroy { /** Horizontal direction in which the list is currently scrolling. */ private _horizontalScrollDirection = AutoScrollHorizontalDirection.NONE; + private flagDays = 0; + constructor( private dragDrop: DragDrop, private dom: GanttDomService, @@ -376,9 +378,15 @@ export class GanttBarDrag implements OnDestroy { this.item.updateDate(start, this.item.end); } else { + if (this.flagDays > 0 && days <= 0) { + this.barElement.style.width = this.ganttUpper.view.cellWidth + 'px'; + const x = this.ganttUpper.view.getXPointByDate(this.item.end); + this.barElement.style.left = x + 'px'; + } this.openDragBackdrop(this.barElement, this.item.end.startOfDay(), this.item.end); this.item.updateDate(this.item.end.startOfDay(), this.item.end); } + this.flagDays = days; } else { const width = this.item.refs.width + distance; const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width); @@ -392,9 +400,13 @@ export class GanttBarDrag implements OnDestroy { } this.item.updateDate(this.item.start, end); } else { + if (this.flagDays > 0 && days <= 0) { + this.barElement.style.width = this.ganttUpper.view.cellWidth + 'px'; + } this.openDragBackdrop(this.barElement, this.item.start, this.item.start.endOfDay()); this.item.updateDate(this.item.start, this.item.start.endOfDay()); } + this.flagDays = days; } this.dragContainer.dragMoved.emit({ item: this.item.origin }); } From 29718351985a79dd2431aa8662476dcaa850f71a Mon Sep 17 00:00:00 2001 From: minlovehua <321512939@qq.com> Date: Mon, 10 Apr 2023 15:58:36 +0800 Subject: [PATCH 2/3] fix(gantt): the fast right (left) dragging start (end) time, the width of bar is wrong #INFR-7111 --- packages/gantt/src/components/bar/bar-drag.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/gantt/src/components/bar/bar-drag.ts b/packages/gantt/src/components/bar/bar-drag.ts index be2e1994..2063b90e 100644 --- a/packages/gantt/src/components/bar/bar-drag.ts +++ b/packages/gantt/src/components/bar/bar-drag.ts @@ -379,7 +379,8 @@ export class GanttBarDrag implements OnDestroy { this.item.updateDate(start, this.item.end); } else { if (this.flagDays > 0 && days <= 0) { - this.barElement.style.width = this.ganttUpper.view.cellWidth + 'px'; + const oneDayWidth = this.ganttUpper.view.getDateRangeWidth(this.item.end.startOfDay(), this.item.end); + this.barElement.style.width = oneDayWidth + 'px'; const x = this.ganttUpper.view.getXPointByDate(this.item.end); this.barElement.style.left = x + 'px'; } @@ -401,7 +402,8 @@ export class GanttBarDrag implements OnDestroy { this.item.updateDate(this.item.start, end); } else { if (this.flagDays > 0 && days <= 0) { - this.barElement.style.width = this.ganttUpper.view.cellWidth + 'px'; + const oneDayWidth = this.ganttUpper.view.getDateRangeWidth(this.item.start, this.item.start.endOfDay()); + this.barElement.style.width = oneDayWidth + 'px'; } this.openDragBackdrop(this.barElement, this.item.start, this.item.start.endOfDay()); this.item.updateDate(this.item.start, this.item.start.endOfDay()); From 350321a298829876b7a85446fce8b635bb904e25 Mon Sep 17 00:00:00 2001 From: minlovehua <321512939@qq.com> Date: Mon, 10 Apr 2023 19:49:41 +0800 Subject: [PATCH 3/3] fix(gantt): modify variable name #INFR-7111 --- packages/gantt/src/components/bar/bar-drag.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/gantt/src/components/bar/bar-drag.ts b/packages/gantt/src/components/bar/bar-drag.ts index 2063b90e..fdd14bd1 100644 --- a/packages/gantt/src/components/bar/bar-drag.ts +++ b/packages/gantt/src/components/bar/bar-drag.ts @@ -74,7 +74,7 @@ export class GanttBarDrag implements OnDestroy { /** Horizontal direction in which the list is currently scrolling. */ private _horizontalScrollDirection = AutoScrollHorizontalDirection.NONE; - private flagDays = 0; + private barHandleDragMoveRecordDays = 0; constructor( private dragDrop: DragDrop, @@ -378,7 +378,7 @@ export class GanttBarDrag implements OnDestroy { this.item.updateDate(start, this.item.end); } else { - if (this.flagDays > 0 && days <= 0) { + if (this.barHandleDragMoveRecordDays > 0 && days <= 0) { const oneDayWidth = this.ganttUpper.view.getDateRangeWidth(this.item.end.startOfDay(), this.item.end); this.barElement.style.width = oneDayWidth + 'px'; const x = this.ganttUpper.view.getXPointByDate(this.item.end); @@ -387,7 +387,7 @@ export class GanttBarDrag implements OnDestroy { this.openDragBackdrop(this.barElement, this.item.end.startOfDay(), this.item.end); this.item.updateDate(this.item.end.startOfDay(), this.item.end); } - this.flagDays = days; + this.barHandleDragMoveRecordDays = days; } else { const width = this.item.refs.width + distance; const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width); @@ -401,14 +401,14 @@ export class GanttBarDrag implements OnDestroy { } this.item.updateDate(this.item.start, end); } else { - if (this.flagDays > 0 && days <= 0) { + if (this.barHandleDragMoveRecordDays > 0 && days <= 0) { const oneDayWidth = this.ganttUpper.view.getDateRangeWidth(this.item.start, this.item.start.endOfDay()); this.barElement.style.width = oneDayWidth + 'px'; } this.openDragBackdrop(this.barElement, this.item.start, this.item.start.endOfDay()); this.item.updateDate(this.item.start, this.item.start.endOfDay()); } - this.flagDays = days; + this.barHandleDragMoveRecordDays = days; } this.dragContainer.dragMoved.emit({ item: this.item.origin }); }