@worktile/gantt 14.0.3 → 14.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/components/bar/bar-drag.mjs +11 -15
- package/esm2020/components/bar/bar.component.mjs +13 -4
- package/esm2020/gantt-dom.service.mjs +2 -1
- package/esm2020/views/view.mjs +3 -3
- package/fesm2015/worktile-gantt.mjs +23 -17
- package/fesm2015/worktile-gantt.mjs.map +1 -1
- package/fesm2020/worktile-gantt.mjs +23 -17
- package/fesm2020/worktile-gantt.mjs.map +1 -1
- package/gantt-dom.service.d.ts +1 -0
- package/package.json +1 -1
|
@@ -474,8 +474,8 @@ class GanttView {
|
|
|
474
474
|
}
|
|
475
475
|
// 根据X坐标获取对应时间
|
|
476
476
|
getDateByXPoint(x) {
|
|
477
|
-
const indexOfSecondaryDate = Math.floor(x / this.getCellWidth());
|
|
478
|
-
const matchDate = this.secondaryDatePoints[indexOfSecondaryDate];
|
|
477
|
+
const indexOfSecondaryDate = Math.max(Math.floor(x / this.getCellWidth()), 0);
|
|
478
|
+
const matchDate = this.secondaryDatePoints[Math.min(this.secondaryDatePoints.length - 1, indexOfSecondaryDate)];
|
|
479
479
|
const dayWidth = this.getDayOccupancyWidth(matchDate?.start);
|
|
480
480
|
if (dayWidth === this.getCellWidth()) {
|
|
481
481
|
return matchDate?.start;
|
|
@@ -2093,6 +2093,7 @@ class GanttDomService {
|
|
|
2093
2093
|
this.container = this.root.getElementsByClassName('gantt-container')[0];
|
|
2094
2094
|
this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
|
|
2095
2095
|
this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
|
|
2096
|
+
this.mainItems = this.root.getElementsByClassName('gantt-main-items')[0];
|
|
2096
2097
|
this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-overlay')[0];
|
|
2097
2098
|
this.monitorScrollChange();
|
|
2098
2099
|
this.disableBrowserWheelEvent();
|
|
@@ -2536,6 +2537,7 @@ class GanttBarDrag {
|
|
|
2536
2537
|
createBarDrag() {
|
|
2537
2538
|
const dragRef = this.dragDrop.createDrag(this.barElement);
|
|
2538
2539
|
dragRef.lockAxis = 'x';
|
|
2540
|
+
dragRef.withBoundaryElement(this.dom.mainItems);
|
|
2539
2541
|
dragRef.started.subscribe(() => {
|
|
2540
2542
|
this.setDraggingStyles();
|
|
2541
2543
|
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
@@ -2552,7 +2554,6 @@ class GanttBarDrag {
|
|
|
2552
2554
|
start = start.addDays(1);
|
|
2553
2555
|
end = end.addDays(1);
|
|
2554
2556
|
}
|
|
2555
|
-
// this.openDragBackdrop(this.barElement, start, end);
|
|
2556
2557
|
this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
|
|
2557
2558
|
this.item.updateDate(start, end);
|
|
2558
2559
|
this.dragContainer.dragMoved.emit({ item: this.item.origin });
|
|
@@ -2573,7 +2574,7 @@ class GanttBarDrag {
|
|
|
2573
2574
|
const isBefore = index === 0;
|
|
2574
2575
|
const dragRef = this.dragDrop.createDrag(handle);
|
|
2575
2576
|
dragRef.lockAxis = 'x';
|
|
2576
|
-
dragRef.withBoundaryElement(this.dom.
|
|
2577
|
+
dragRef.withBoundaryElement(this.dom.mainItems);
|
|
2577
2578
|
dragRef.started.subscribe(() => {
|
|
2578
2579
|
this.setDraggingStyles();
|
|
2579
2580
|
this.dragContainer.dragStarted.emit({ item: this.item.origin });
|
|
@@ -2582,20 +2583,22 @@ class GanttBarDrag {
|
|
|
2582
2583
|
if (isBefore) {
|
|
2583
2584
|
const x = this.item.refs.x + event.distance.x;
|
|
2584
2585
|
const width = this.item.refs.width + event.distance.x * -1;
|
|
2586
|
+
const start = this.ganttUpper.view.getDateByXPoint(x);
|
|
2585
2587
|
if (width > dragMinWidth) {
|
|
2586
2588
|
this.barElement.style.width = width + 'px';
|
|
2587
2589
|
this.barElement.style.left = x + 'px';
|
|
2588
|
-
this.openDragBackdrop(this.barElement,
|
|
2589
|
-
this.item.updateDate(
|
|
2590
|
+
this.openDragBackdrop(this.barElement, start, this.item.end);
|
|
2591
|
+
this.item.updateDate(start, this.item.end);
|
|
2590
2592
|
}
|
|
2591
2593
|
}
|
|
2592
2594
|
else {
|
|
2593
2595
|
const width = this.item.refs.width + event.distance.x;
|
|
2596
|
+
const end = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width);
|
|
2594
2597
|
if (width > dragMinWidth) {
|
|
2595
2598
|
this.barElement.style.width = width + 'px';
|
|
2596
|
-
this.openDragBackdrop(this.barElement, this.item.start,
|
|
2599
|
+
this.openDragBackdrop(this.barElement, this.item.start, end);
|
|
2600
|
+
this.item.updateDate(this.item.start, end);
|
|
2597
2601
|
}
|
|
2598
|
-
this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
|
|
2599
2602
|
}
|
|
2600
2603
|
this.dragContainer.dragMoved.emit({ item: this.item.origin });
|
|
2601
2604
|
event.source.reset();
|
|
@@ -2603,19 +2606,13 @@ class GanttBarDrag {
|
|
|
2603
2606
|
dragRef.ended.subscribe((event) => {
|
|
2604
2607
|
if (isBefore) {
|
|
2605
2608
|
const width = this.item.refs.width + event.distance.x * -1;
|
|
2606
|
-
if (width
|
|
2607
|
-
this.item.updateDate(this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x), this.item.end);
|
|
2608
|
-
}
|
|
2609
|
-
else {
|
|
2609
|
+
if (width <= dragMinWidth) {
|
|
2610
2610
|
this.item.updateDate(this.item.end.startOfDay(), this.item.end);
|
|
2611
2611
|
}
|
|
2612
2612
|
}
|
|
2613
2613
|
else {
|
|
2614
2614
|
const width = this.item.refs.width + event.distance.x;
|
|
2615
|
-
if (width
|
|
2616
|
-
this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + this.item.refs.width + event.distance.x));
|
|
2617
|
-
}
|
|
2618
|
-
else {
|
|
2615
|
+
if (width <= dragMinWidth) {
|
|
2619
2616
|
this.item.updateDate(this.item.start, this.item.start.endOfDay());
|
|
2620
2617
|
}
|
|
2621
2618
|
}
|
|
@@ -2841,7 +2838,16 @@ class NgxGanttBarComponent extends GanttItemUpper {
|
|
|
2841
2838
|
});
|
|
2842
2839
|
}
|
|
2843
2840
|
ngAfterViewInit() {
|
|
2844
|
-
|
|
2841
|
+
// Note: the zone may be nooped through `BootstrapOptions` when bootstrapping the root module. This means
|
|
2842
|
+
// the `onStable` will never emit any value.
|
|
2843
|
+
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1));
|
|
2844
|
+
// Normally this isn't in the zone, but it can cause performance regressions for apps
|
|
2845
|
+
// using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
|
|
2846
|
+
this.ngZone.runOutsideAngular(() => {
|
|
2847
|
+
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
|
|
2848
|
+
this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
|
|
2849
|
+
});
|
|
2850
|
+
});
|
|
2845
2851
|
this.setContentBackground();
|
|
2846
2852
|
this.handles.changes
|
|
2847
2853
|
.pipe(startWith(this.handles), switchMap(() =>
|