@worktile/gantt 15.1.0-next.0 → 15.1.0-next.2

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.
Files changed (33) hide show
  1. package/components/bar/bar-drag.d.ts +18 -4
  2. package/components/bar/bar.component.scss +0 -22
  3. package/components/drag-backdrop/drag-backdrop.component.scss +1 -0
  4. package/components/loader/loader.component.d.ts +5 -0
  5. package/components/loader/loader.component.scss +90 -0
  6. package/components/table/body/gantt-table-body.component.d.ts +1 -1
  7. package/esm2020/components/bar/bar-drag.mjs +106 -31
  8. package/esm2020/components/bar/bar.component.mjs +32 -27
  9. package/esm2020/components/loader/loader.component.mjs +29 -0
  10. package/esm2020/components/table/body/gantt-table-body.component.mjs +22 -9
  11. package/esm2020/components/table/header/gantt-table-header.component.mjs +2 -2
  12. package/esm2020/gantt-abstract.mjs +1 -1
  13. package/esm2020/gantt-item-upper.mjs +8 -5
  14. package/esm2020/gantt.component.mjs +40 -12
  15. package/esm2020/gantt.module.mjs +4 -1
  16. package/esm2020/public-api.mjs +2 -1
  17. package/esm2020/table/gantt-column.component.mjs +8 -4
  18. package/esm2020/utils/drag-scroll.mjs +35 -0
  19. package/fesm2015/worktile-gantt.mjs +270 -78
  20. package/fesm2015/worktile-gantt.mjs.map +1 -1
  21. package/fesm2020/worktile-gantt.mjs +267 -78
  22. package/fesm2020/worktile-gantt.mjs.map +1 -1
  23. package/gantt-abstract.d.ts +2 -1
  24. package/gantt-item-upper.d.ts +1 -0
  25. package/gantt.component.d.ts +6 -1
  26. package/gantt.component.scss +4 -0
  27. package/gantt.module.d.ts +13 -12
  28. package/package.json +1 -1
  29. package/public-api.d.ts +1 -0
  30. package/styles/index.scss +1 -0
  31. package/styles/variables.scss +3 -0
  32. package/table/gantt-column.component.d.ts +4 -2
  33. package/utils/drag-scroll.d.ts +20 -0
@@ -3,12 +3,12 @@ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, Content
3
3
  import * as i1 from '@angular/common';
4
4
  import { DOCUMENT, isPlatformServer, CommonModule } from '@angular/common';
5
5
  import { take, takeUntil, skip, switchMap, debounceTime as debounceTime$1, map, pairwise, auditTime, startWith as startWith$1, finalize } from 'rxjs/operators';
6
- import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, debounceTime, filter, merge, EMPTY, fromEvent, Observable } from 'rxjs';
6
+ import { BehaviorSubject, Subject, from, takeUntil as takeUntil$1, startWith, debounceTime, filter, merge, EMPTY, fromEvent, Observable, interval, animationFrameScheduler } from 'rxjs';
7
7
  import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
8
8
  export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
9
9
  import { SelectionModel } from '@angular/cdk/collections';
10
10
  import { coerceBooleanProperty, coerceCssPixelValue } from '@angular/cdk/coercion';
11
- import * as i2$1 from '@angular/cdk/scrolling';
11
+ import * as i3 from '@angular/cdk/scrolling';
12
12
  import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
13
13
  import { __awaiter, __decorate, __param } from 'tslib';
14
14
  import * as i2 from '@angular/cdk/drag-drop';
@@ -1242,11 +1242,15 @@ class NgxGanttTableColumnComponent {
1242
1242
  set width(width) {
1243
1243
  this.columnWidth = coerceCssPixelValue(width);
1244
1244
  }
1245
- constructor(ganttUpper) {
1245
+ constructor(ganttUpper, elementRef) {
1246
1246
  this.ganttUpper = ganttUpper;
1247
+ this.elementRef = elementRef;
1248
+ }
1249
+ get classList() {
1250
+ return this.elementRef.nativeElement.classList;
1247
1251
  }
1248
1252
  }
1249
- NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
1253
+ NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1250
1254
  NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name", showExpandIcon: "showExpandIcon" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1251
1255
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttTableColumnComponent, decorators: [{
1252
1256
  type: Component,
@@ -1258,7 +1262,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1258
1262
  return [{ type: GanttUpper, decorators: [{
1259
1263
  type: Inject,
1260
1264
  args: [GANTT_UPPER_TOKEN]
1261
- }] }];
1265
+ }] }, { type: i0.ElementRef }];
1262
1266
  }, propDecorators: { width: [{
1263
1267
  type: Input
1264
1268
  }], name: [{
@@ -1430,7 +1434,7 @@ class GanttTableHeaderComponent {
1430
1434
  this.columnsChange();
1431
1435
  this.columns.changes.pipe(takeUntil$1(this.unsubscribe$)).subscribe(() => {
1432
1436
  this.columnsChange();
1433
- this.cdr.detectChanges();
1437
+ this.gantt.cdr.detectChanges();
1434
1438
  });
1435
1439
  }
1436
1440
  columnsChange() {
@@ -1744,6 +1748,7 @@ class GanttTableBodyComponent {
1744
1748
  this.columns.changes.pipe(startWith(this.columns), takeUntil$1(this.destroy$)).subscribe(() => {
1745
1749
  this.hasExpandIcon = false;
1746
1750
  this.columns.forEach((column) => {
1751
+ column.classList.add('gantt-table-column');
1747
1752
  if (!column.columnWidth) {
1748
1753
  column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1749
1754
  }
@@ -1784,7 +1789,7 @@ class GanttTableBodyComponent {
1784
1789
  onItemDragStarted(event) {
1785
1790
  this.ganttTableDragging = true;
1786
1791
  // 拖动开始时隐藏所有的子项
1787
- const children = this.getChildrenElementsByDragRef(event.source);
1792
+ const children = this.getChildrenElementsByElement(event.source.getPlaceholderElement());
1788
1793
  children.forEach((element) => {
1789
1794
  element.classList.add('drag-item-hide');
1790
1795
  });
@@ -1874,9 +1879,21 @@ class GanttTableBodyComponent {
1874
1879
  this.flatData.splice(this.flatData.indexOf(item), 1);
1875
1880
  }
1876
1881
  insertItem(target, inserted, position) {
1877
- const appendIndex = position === 'after' ? 1 : 0;
1878
- this.renderData.splice(this.renderData.indexOf(target) + appendIndex, 0, inserted);
1879
- this.flatData.splice(this.flatData.indexOf(target) + appendIndex, 0, inserted);
1882
+ var _a;
1883
+ if (position === 'before') {
1884
+ this.renderData.splice(this.renderData.indexOf(target), 0, inserted);
1885
+ this.flatData.splice(this.flatData.indexOf(target), 0, inserted);
1886
+ }
1887
+ else {
1888
+ const dragRef = this.cdkDrags.find((drag) => drag.data === target);
1889
+ // 如果目标项是展开的,插入的 index 位置需要考虑子项的数量
1890
+ let childrenCount = 0;
1891
+ if (target.expanded) {
1892
+ childrenCount = ((_a = this.getChildrenElementsByElement(dragRef.element.nativeElement)) === null || _a === void 0 ? void 0 : _a.length) || 0;
1893
+ }
1894
+ this.renderData.splice(this.renderData.indexOf(target) + 1 + childrenCount, 0, inserted);
1895
+ this.flatData.splice(this.flatData.indexOf(target) + 1 + childrenCount, 0, inserted);
1896
+ }
1880
1897
  }
1881
1898
  insertChildrenItem(target, inserted) {
1882
1899
  if (target.expanded) {
@@ -1891,10 +1908,11 @@ class GanttTableBodyComponent {
1891
1908
  return (_a = n.children) === null || _a === void 0 ? void 0 : _a.includes(item);
1892
1909
  });
1893
1910
  }
1894
- getChildrenElementsByDragRef(dragRef) {
1911
+ getChildrenElementsByElement(element) {
1895
1912
  // 通过循环持续查找 next element,如果 element 的 level 小于当前 item 的 level,则为它的 children
1896
1913
  const children = [];
1897
- let nextElement = dragRef.getPlaceholderElement().nextElementSibling;
1914
+ const dragRef = this.itemDragRefMap.get(element);
1915
+ let nextElement = element.nextElementSibling;
1898
1916
  let nextDragRef = this.itemDragRefMap.get(nextElement);
1899
1917
  while (nextDragRef && nextDragRef.data.level > dragRef.data.level) {
1900
1918
  children.push(nextElement);
@@ -1934,10 +1952,10 @@ class GanttTableBodyComponent {
1934
1952
  }
1935
1953
  }
1936
1954
  GanttTableBodyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableBodyComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }, { token: GANTT_UPPER_TOKEN }, { token: i0.ChangeDetectorRef }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
1937
- GanttTableBodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: { renderData: "renderData", flatData: "flatData", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate", draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", itemClick: "itemClick" }, host: { properties: { "class.gantt-table-draggable": "this.draggable", "class.gantt-table-body": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass", "class.gantt-table-dragging": "this.ganttTableDragging" } }, viewQueries: [{ propertyName: "cdkDrags", predicate: (CdkDrag), descendants: true }], ngImport: i0, template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i2.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i2.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }] });
1955
+ GanttTableBodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: { renderData: "renderData", flatData: "flatData", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate", rowBeforeTemplate: "rowBeforeTemplate", rowAfterTemplate: "rowAfterTemplate", draggable: "draggable", dropEnterPredicate: "dropEnterPredicate" }, outputs: { dragDropped: "dragDropped", itemClick: "itemClick" }, host: { properties: { "class.gantt-table-draggable": "this.draggable", "class.gantt-table-body": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass", "class.gantt-table-dragging": "this.ganttTableDragging" } }, viewQueries: [{ propertyName: "cdkDrags", predicate: (CdkDrag), descendants: true }], ngImport: i0, template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div [classList]=\"column.classList\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i2.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i2.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "component", type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }, { kind: "pipe", type: IsGanttRangeItemPipe, name: "isGanttRangeItem" }] });
1938
1956
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttTableBodyComponent, decorators: [{
1939
1957
  type: Component,
1940
- args: [{ selector: 'gantt-table-body', template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div class=\"gantt-table-column\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n" }]
1958
+ args: [{ selector: 'gantt-table-body', template: "<div\n class=\"gantt-table-body-container\"\n cdkDropList\n [cdkDropListAutoScrollStep]=\"6\"\n [cdkDropListData]=\"renderData\"\n [cdkDropListSortingDisabled]=\"true\"\n (cdkDropListDropped)=\"onListDropped($event)\"\n>\n <ng-container *ngIf=\"!renderData?.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"renderData && renderData.length > 0\">\n <ng-container *ngFor=\"let item of renderData; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"item.class\" *ngIf=\"item.items\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"item.expanded\" (click)=\"expandGroup(item)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, group: item.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ item.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <div\n *ngIf=\"!item.items\"\n (click)=\"itemClick.emit({ event: $event, selectedValue: item.origin })\"\n cdkDrag\n [cdkDragData]=\"item\"\n [cdkDragDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n (cdkDragStarted)=\"onItemDragStarted($event)\"\n (cdkDragEnded)=\"onItemDragEnded($event)\"\n (cdkDragMoved)=\"emitItemDragMoved($event)\"\n class=\"gantt-table-item\"\n [class.gantt-table-item-with-group]=\"hasGroup\"\n [class.gantt-table-item-first-level-group]=\"item.level === 0 && (item.type | isGanttRangeItem)\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n [class.gantt-table-item-active]=\"ganttUpper.isSelected(item.id)\"\n >\n <ng-template\n [ngTemplateOutlet]=\"rowBeforeTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n\n <div [classList]=\"column.classList\" *ngFor=\"let column of columns; let first = first\" [style.width]=\"column.columnWidth\">\n <!-- drag icon -->\n <gantt-icon\n *ngIf=\"first && draggable\"\n class=\"gantt-drag-handle\"\n iconName=\"drag\"\n cdkDragHandle\n [cdkDragHandleDisabled]=\"(draggable && item.itemDraggable === false) || !draggable\"\n ></gantt-icon>\n <!-- expand icon -->\n <div\n *ngIf=\"column?.showExpandIcon || (!hasExpandIcon && first)\"\n class=\"gantt-expand-icon\"\n [style.marginLeft.px]=\"item.level * 20\"\n >\n <ng-container *ngIf=\"item.level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren($event, item)\"\n >\n </gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <!-- column content -->\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n <ng-template\n [ngTemplateOutlet]=\"rowAfterTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </ng-container>\n </ng-container>\n</div>\n" }]
1941
1959
  }], ctorParameters: function () {
1942
1960
  return [{ type: undefined, decorators: [{
1943
1961
  type: Inject,
@@ -2458,6 +2476,41 @@ function normalizePassiveListenerOptions(options) {
2458
2476
  /** Options used to bind passive event listeners. */
2459
2477
  const passiveListenerOptions = normalizePassiveListenerOptions({ passive: true });
2460
2478
 
2479
+ /**
2480
+ * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
2481
+ * viewport. The value comes from trying it out manually until it feels right.
2482
+ */
2483
+ const SCROLL_PROXIMITY_THRESHOLD = 0.05;
2484
+ /**
2485
+ * Gets whether the horizontal auto-scroll direction of a node.
2486
+ * @param clientRect Dimensions of the node.
2487
+ * @param pointerX Position of the user's pointer along the x axis.
2488
+ */
2489
+ function getHorizontalScrollDirection(clientRect, pointerX) {
2490
+ const { left, right, width } = clientRect;
2491
+ const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
2492
+ if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
2493
+ return 1 /* AutoScrollHorizontalDirection.LEFT */;
2494
+ }
2495
+ else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
2496
+ return 2 /* AutoScrollHorizontalDirection.RIGHT */;
2497
+ }
2498
+ return 0 /* AutoScrollHorizontalDirection.NONE */;
2499
+ }
2500
+ /**
2501
+ * Checks whether the pointer coordinates are close to a ClientRect.
2502
+ * @param rect ClientRect to check against.
2503
+ * @param threshold Threshold around the ClientRect.
2504
+ * @param pointerX Coordinates along the X axis.
2505
+ * @param pointerY Coordinates along the Y axis.
2506
+ */
2507
+ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
2508
+ const { top, right, bottom, left, width, height } = rect;
2509
+ const xThreshold = width * threshold;
2510
+ const yThreshold = height * threshold;
2511
+ return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
2512
+ }
2513
+
2461
2514
  const scrollThreshold = 50;
2462
2515
  var ScrollDirection;
2463
2516
  (function (ScrollDirection) {
@@ -2826,7 +2879,7 @@ class NgxGanttRootComponent {
2826
2879
  }
2827
2880
  }
2828
2881
  NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: GanttDomService }, { token: GanttDragContainer }, { token: GANTT_UPPER_TOKEN }, { token: GanttPrintService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
2829
- NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { classAttribute: "gantt" }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], viewQueries: [{ propertyName: "backdrop", first: true, predicate: GanttDragBackdropComponent, descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" *ngIf=\"sideTemplate\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\" cdkScrollable>\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\" *ngIf=\"mainTemplate\">\n <gantt-calendar-header></gantt-calendar-header>\n <gantt-calendar-grid></gantt-calendar-grid>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<ng-content></ng-content>\n<gantt-toolbar *ngIf=\"ganttUpper.showToolbar || ganttUpper.toolbarTemplate\" [template]=\"ganttUpper.toolbarTemplate\"> </gantt-toolbar>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2$1.CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: ["template"] }] });
2882
+ NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { classAttribute: "gantt" }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], viewQueries: [{ propertyName: "backdrop", first: true, predicate: GanttDragBackdropComponent, descendants: true, read: ElementRef, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" *ngIf=\"sideTemplate\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\" cdkScrollable>\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\" *ngIf=\"mainTemplate\">\n <gantt-calendar-header></gantt-calendar-header>\n <gantt-calendar-grid></gantt-calendar-grid>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n<ng-content></ng-content>\n<gantt-toolbar *ngIf=\"ganttUpper.showToolbar || ganttUpper.toolbarTemplate\" [template]=\"ganttUpper.toolbarTemplate\"> </gantt-toolbar>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i3.CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttToolbarComponent, selector: "ngx-gantt-toolbar,gantt-toolbar", inputs: ["template"] }] });
2830
2883
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
2831
2884
  type: Component,
2832
2885
  args: [{ selector: 'ngx-gantt-root', providers: [GanttDomService, GanttDragContainer], host: {
@@ -2852,8 +2905,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
2852
2905
  args: [GanttDragBackdropComponent, { static: true, read: ElementRef }]
2853
2906
  }] } });
2854
2907
 
2908
+ /**
2909
+ * Proximity, as a ratio to width/height, at which a
2910
+ * dragged item will affect the drop container.
2911
+ */
2912
+ const DROP_PROXIMITY_THRESHOLD = 0.05;
2855
2913
  const dragMinWidth = 10;
2856
- const autoScrollStep = 10;
2914
+ const autoScrollStep = 5;
2857
2915
  const activeClass = 'gantt-bar-active';
2858
2916
  const dropActiveClass = 'gantt-bar-drop-active';
2859
2917
  const singleDropActiveClass = 'gantt-bar-single-drop-active';
@@ -2869,19 +2927,44 @@ class GanttBarDrag {
2869
2927
  get linkDragDisabled() {
2870
2928
  return !this.item.linkable || !this.ganttUpper.linkable;
2871
2929
  }
2872
- constructor(dragDrop, dom, dragContainer, root) {
2930
+ constructor(dragDrop, dom, dragContainer, _ngZone, root) {
2873
2931
  this.dragDrop = dragDrop;
2874
2932
  this.dom = dom;
2875
2933
  this.dragContainer = dragContainer;
2934
+ this._ngZone = _ngZone;
2876
2935
  this.root = root;
2877
2936
  this.dragRefs = [];
2878
2937
  this.destroy$ = new Subject();
2879
- // scrolling state when drag
2938
+ /** Used to signal to the current auto-scroll sequence when to stop. */
2939
+ this.stopScrollTimers$ = new Subject();
2940
+ /** move distance when drag bar */
2941
+ this.barDragMoveDistance = 0;
2942
+ /** move distance when drag bar handle */
2943
+ this.barHandleDragMoveDistance = 0;
2944
+ /** scrolling state when drag */
2880
2945
  this.dragScrolling = false;
2946
+ /** dragScrollDistance */
2947
+ this.dragScrollDistance = 0;
2948
+ /** Horizontal direction in which the list is currently scrolling. */
2949
+ this._horizontalScrollDirection = 0 /* AutoScrollHorizontalDirection.NONE */;
2950
+ this.startScrollInterval = () => {
2951
+ this.stopScrolling();
2952
+ interval(0, animationFrameScheduler)
2953
+ .pipe(takeUntil(this.stopScrollTimers$))
2954
+ .subscribe(() => {
2955
+ const node = this.dom.mainContainer;
2956
+ const scrollStep = autoScrollStep;
2957
+ if (this._horizontalScrollDirection === 1 /* AutoScrollHorizontalDirection.LEFT */) {
2958
+ node.scrollBy(-scrollStep, 0);
2959
+ }
2960
+ else if (this._horizontalScrollDirection === 2 /* AutoScrollHorizontalDirection.RIGHT */) {
2961
+ node.scrollBy(scrollStep, 0);
2962
+ }
2963
+ });
2964
+ };
2881
2965
  }
2882
2966
  createDragRef(element) {
2883
2967
  const dragRef = this.dragDrop.createDrag(element);
2884
- // dragRef.withPreviewContainer(this.dom.mainContainer as HTMLElement);
2885
2968
  return dragRef;
2886
2969
  }
2887
2970
  createDragScrollEvent(dragRef) {
@@ -2929,18 +3012,19 @@ class GanttBarDrag {
2929
3012
  this.setDraggingStyles();
2930
3013
  this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2931
3014
  this.createDragScrollEvent(dragRef).subscribe(() => {
2932
- if (this.dropListRef.isDragging()) {
2933
- this.dragScrolling = true;
2934
- const scrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2935
- this.barDragMove(dragRef, scrollDistance + this.barDragMoveDistance);
3015
+ if (dragRef.isDragging()) {
3016
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
3017
+ this.dragScrollDistance = dragScrollDistance;
3018
+ this.barDragMove();
2936
3019
  }
2937
3020
  });
2938
3021
  this.dragContainer.dragStarted.emit({ item: this.item.origin });
2939
3022
  });
2940
3023
  dragRef.moved.subscribe((event) => {
2941
- this.barDragMove(dragRef, event.distance.x);
3024
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
3025
+ this.barDragMoveDistance = event.distance.x;
2942
3026
  if (!this.dragScrolling) {
2943
- this.barDragMoveDistance = event.distance.x;
3027
+ this.barDragMove();
2944
3028
  }
2945
3029
  });
2946
3030
  dragRef.ended.subscribe((event) => {
@@ -2952,7 +3036,9 @@ class GanttBarDrag {
2952
3036
  this.clearDraggingStyles();
2953
3037
  this.closeDragBackdrop();
2954
3038
  event.source.reset();
3039
+ this.stopScrolling();
2955
3040
  this.dragScrolling = false;
3041
+ this.dragScrollDistance = 0;
2956
3042
  this.barDragMoveDistance = 0;
2957
3043
  this.dragContainer.dragEnded.emit({ item: this.item.origin });
2958
3044
  });
@@ -2971,18 +3057,19 @@ class GanttBarDrag {
2971
3057
  this.setDraggingStyles();
2972
3058
  this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
2973
3059
  this.createDragScrollEvent(dragRef).subscribe(() => {
2974
- if (this.dropListRef.isDragging()) {
2975
- this.dragScrolling = true;
2976
- const scrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
2977
- this.barHandleDragMove(scrollDistance + this.barHandleDragMoveDistance, isBefore);
3060
+ if (dragRef.isDragging()) {
3061
+ const dragScrollDistance = this.dom.mainContainer.scrollLeft - this.containerScrollLeft;
3062
+ this.dragScrollDistance = dragScrollDistance;
3063
+ this.barHandleDragMove(isBefore);
2978
3064
  }
2979
3065
  });
2980
3066
  this.dragContainer.dragStarted.emit({ item: this.item.origin });
2981
3067
  });
2982
3068
  dragRef.moved.subscribe((event) => {
2983
- this.barHandleDragMove(event.distance.x, isBefore);
3069
+ this.startScrollingIfNecessary(event.pointerPosition.x, event.pointerPosition.y);
3070
+ this.barHandleDragMoveDistance = event.distance.x;
2984
3071
  if (!this.dragScrolling) {
2985
- this.barHandleDragMoveDistance = event.distance.x;
3072
+ this.barHandleDragMove(isBefore);
2986
3073
  }
2987
3074
  });
2988
3075
  dragRef.ended.subscribe((event) => {
@@ -3006,7 +3093,9 @@ class GanttBarDrag {
3006
3093
  this.clearDraggingStyles();
3007
3094
  this.closeDragBackdrop();
3008
3095
  event.source.reset();
3096
+ this.stopScrolling();
3009
3097
  this.dragScrolling = false;
3098
+ this.dragScrollDistance = 0;
3010
3099
  this.barHandleDragMoveDistance = 0;
3011
3100
  this.dragContainer.dragEnded.emit({ item: this.item.origin });
3012
3101
  });
@@ -3096,8 +3185,8 @@ class GanttBarDrag {
3096
3185
  this.barElement.style.pointerEvents = '';
3097
3186
  this.barElement.classList.remove('gantt-bar-draggable-drag');
3098
3187
  }
3099
- barDragMove(dragRef, distance) {
3100
- const currentX = this.item.refs.x + distance;
3188
+ barDragMove() {
3189
+ const currentX = this.item.refs.x + this.barDragMoveDistance + this.dragScrollDistance;
3101
3190
  const currentDate = this.ganttUpper.view.getDateByXPoint(currentX);
3102
3191
  const currentStartX = this.ganttUpper.view.getXPointByDate(currentDate);
3103
3192
  const dayWidth = this.ganttUpper.view.getDayOccupancyWidth(currentDate);
@@ -3108,11 +3197,18 @@ class GanttBarDrag {
3108
3197
  start = start.addDays(1);
3109
3198
  end = end.addDays(1);
3110
3199
  }
3111
- this.openDragBackdrop(dragRef['_preview'], this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
3200
+ if (this.dragScrolling) {
3201
+ this.barElement.style.left = currentX - this.barDragMoveDistance + 'px';
3202
+ }
3203
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(currentX), this.ganttUpper.view.getDateByXPoint(currentX + this.item.refs.width));
3204
+ if (!this.isStartOrEndInsideView(start, end)) {
3205
+ return;
3206
+ }
3112
3207
  this.item.updateDate(start, end);
3113
3208
  this.dragContainer.dragMoved.emit({ item: this.item.origin });
3114
3209
  }
3115
- barHandleDragMove(distance, isBefore) {
3210
+ barHandleDragMove(isBefore) {
3211
+ const distance = this.barHandleDragMoveDistance + this.dragScrollDistance;
3116
3212
  if (isBefore) {
3117
3213
  const x = this.item.refs.x + distance;
3118
3214
  const width = this.item.refs.width + distance * -1;
@@ -3121,6 +3217,9 @@ class GanttBarDrag {
3121
3217
  this.barElement.style.width = width + 'px';
3122
3218
  this.barElement.style.left = x + 'px';
3123
3219
  this.openDragBackdrop(this.barElement, start, this.item.end);
3220
+ if (!this.isStartOrEndInsideView(start, this.item.end)) {
3221
+ return;
3222
+ }
3124
3223
  this.item.updateDate(start, this.item.end);
3125
3224
  }
3126
3225
  }
@@ -3130,6 +3229,9 @@ class GanttBarDrag {
3130
3229
  if (width > dragMinWidth) {
3131
3230
  this.barElement.style.width = width + 'px';
3132
3231
  this.openDragBackdrop(this.barElement, this.item.start, end);
3232
+ if (!this.isStartOrEndInsideView(this.item.start, end)) {
3233
+ return;
3234
+ }
3133
3235
  this.item.updateDate(this.item.start, end);
3134
3236
  }
3135
3237
  }
@@ -3162,6 +3264,36 @@ class GanttBarDrag {
3162
3264
  this.linkDraggingLine = null;
3163
3265
  }
3164
3266
  }
3267
+ startScrollingIfNecessary(pointerX, pointerY) {
3268
+ const clientRect = this.dom.mainContainer.getBoundingClientRect();
3269
+ if (isPointerNearClientRect(clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
3270
+ const horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
3271
+ if (horizontalScrollDirection) {
3272
+ this._horizontalScrollDirection = horizontalScrollDirection;
3273
+ this.dragScrolling = true;
3274
+ this._ngZone.runOutsideAngular(this.startScrollInterval);
3275
+ }
3276
+ else {
3277
+ this.dragScrolling = false;
3278
+ this.stopScrolling();
3279
+ }
3280
+ }
3281
+ }
3282
+ stopScrolling() {
3283
+ this.stopScrollTimers$.next();
3284
+ }
3285
+ isStartOrEndInsideView(start, end) {
3286
+ const itemStart = start.getUnixTime();
3287
+ const itemEnd = end.getUnixTime();
3288
+ const viewStart = this.ganttUpper.view.start.getUnixTime();
3289
+ const viewEnd = this.ganttUpper.view.end.getUnixTime();
3290
+ if (itemStart < viewStart || itemEnd > viewEnd) {
3291
+ return false;
3292
+ }
3293
+ else {
3294
+ return true;
3295
+ }
3296
+ }
3165
3297
  createDrags(elementRef, item, ganttUpper) {
3166
3298
  this.item = item;
3167
3299
  this.barElement = elementRef.nativeElement;
@@ -3175,13 +3307,6 @@ class GanttBarDrag {
3175
3307
  const dragRef = this.createBarDrag();
3176
3308
  const dragHandlesRefs = this.createBarHandleDrags();
3177
3309
  this.dragRefs.push(dragRef, ...dragHandlesRefs);
3178
- // 创建拖拽容器并将所有元素添加到容器中,利用容器来实现自动滚动
3179
- if (!this.dropListRef) {
3180
- this.dropListRef = this.dragDrop.createDropList(this.dom.mainContainer);
3181
- this.dropListRef.autoScrollStep = autoScrollStep;
3182
- this.dropListRef.withOrientation('horizontal');
3183
- }
3184
- this.dropListRef.withItems([dragRef, ...dragHandlesRefs]);
3185
3310
  }
3186
3311
  if (!this.linkDragDisabled) {
3187
3312
  const linkDragRefs = this.createLinkHandleDrags();
@@ -3197,14 +3322,16 @@ class GanttBarDrag {
3197
3322
  this.dragRefs.forEach((dragRef) => dragRef.dispose());
3198
3323
  this.destroy$.next();
3199
3324
  this.destroy$.complete();
3325
+ this.stopScrolling();
3326
+ this.stopScrollTimers$.complete();
3200
3327
  }
3201
3328
  }
3202
- GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i2.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
3329
+ GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, deps: [{ token: i2.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }, { token: i0.NgZone }, { token: NgxGanttRootComponent, skipSelf: true }], target: i0.ɵɵFactoryTarget.Injectable });
3203
3330
  GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag });
3204
3331
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttBarDrag, decorators: [{
3205
3332
  type: Injectable
3206
3333
  }], ctorParameters: function () {
3207
- return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: NgxGanttRootComponent, decorators: [{
3334
+ return [{ type: i2.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }, { type: i0.NgZone }, { type: NgxGanttRootComponent, decorators: [{
3208
3335
  type: SkipSelf
3209
3336
  }] }];
3210
3337
  } });
@@ -3215,10 +3342,11 @@ class GanttItemUpper {
3215
3342
  this.ganttUpper = ganttUpper;
3216
3343
  this.firstChange = true;
3217
3344
  this.unsubscribe$ = new Subject();
3345
+ this.refsUnsubscribe$ = new Subject();
3218
3346
  }
3219
3347
  ngOnInit() {
3220
3348
  this.firstChange = false;
3221
- this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3349
+ this.item.refs$.pipe(takeUntil(this.refsUnsubscribe$)).subscribe(() => {
3222
3350
  this.setPositions();
3223
3351
  });
3224
3352
  }
@@ -3228,11 +3356,11 @@ class GanttItemUpper {
3228
3356
  }
3229
3357
  }
3230
3358
  itemChange(item) {
3231
- this.unsubscribe$.next();
3232
- this.unsubscribe$.complete();
3359
+ this.refsUnsubscribe$.next();
3360
+ this.refsUnsubscribe$.complete();
3233
3361
  this.item = item;
3234
3362
  this.setPositions();
3235
- this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
3363
+ this.item.refs$.pipe(takeUntil(this.refsUnsubscribe$)).subscribe(() => {
3236
3364
  this.setPositions();
3237
3365
  });
3238
3366
  }
@@ -3252,6 +3380,8 @@ class GanttItemUpper {
3252
3380
  ngOnDestroy() {
3253
3381
  this.unsubscribe$.next();
3254
3382
  this.unsubscribe$.complete();
3383
+ this.refsUnsubscribe$.next();
3384
+ this.refsUnsubscribe$.complete();
3255
3385
  }
3256
3386
  }
3257
3387
  GanttItemUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttItemUpper, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Directive });
@@ -3289,9 +3419,13 @@ class NgxGanttBarComponent extends GanttItemUpper {
3289
3419
  });
3290
3420
  }
3291
3421
  ngOnChanges(changes) {
3422
+ var _a, _b;
3292
3423
  super.ngOnChanges(changes);
3293
3424
  if (!this.firstChange) {
3294
3425
  this.drag.updateItem(this.item);
3426
+ if (((_a = changes.item.currentValue.refs) === null || _a === void 0 ? void 0 : _a.width) !== ((_b = changes.item.previousValue.refs) === null || _b === void 0 ? void 0 : _b.width)) {
3427
+ this.setContentBackground();
3428
+ }
3295
3429
  }
3296
3430
  }
3297
3431
  ngAfterViewInit() {
@@ -3319,30 +3453,33 @@ class NgxGanttBarComponent extends GanttItemUpper {
3319
3453
  this.barClick.emit({ event, item: this.item.origin });
3320
3454
  }
3321
3455
  setContentBackground() {
3322
- const contentElement = this.contentElementRef.nativeElement;
3323
- const color = this.item.color || barBackground;
3324
- const style = this.item.barStyle || {};
3325
- if (this.item.origin.start && this.item.origin.end) {
3326
- style.background = color;
3327
- style.borderRadius = '';
3328
- }
3329
- if (this.item.origin.start && !this.item.origin.end) {
3330
- style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
3331
- style.borderRadius = '4px 12.5px 12.5px 4px';
3332
- }
3333
- if (!this.item.origin.start && this.item.origin.end) {
3334
- style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
3335
- style.borderRadius = '12.5px 4px 4px 12.5px';
3336
- }
3337
- if (this.item.progress >= 0) {
3338
- const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
3339
- style.background = hexToRgb(color, 0.3);
3340
- style.borderRadius = '';
3341
- contentProgressElement.style.background = color;
3342
- }
3343
- for (const key in style) {
3344
- if (style.hasOwnProperty(key)) {
3345
- contentElement.style[key] = style[key];
3456
+ var _a;
3457
+ if ((_a = this.item.refs) === null || _a === void 0 ? void 0 : _a.width) {
3458
+ const contentElement = this.contentElementRef.nativeElement;
3459
+ const color = this.item.color || barBackground;
3460
+ const style = this.item.barStyle || {};
3461
+ if (this.item.origin.start && this.item.origin.end) {
3462
+ style.background = color;
3463
+ style.borderRadius = '';
3464
+ }
3465
+ if (this.item.origin.start && !this.item.origin.end) {
3466
+ style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
3467
+ style.borderRadius = '4px 12.5px 12.5px 4px';
3468
+ }
3469
+ if (!this.item.origin.start && this.item.origin.end) {
3470
+ style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
3471
+ style.borderRadius = '12.5px 4px 4px 12.5px';
3472
+ }
3473
+ if (this.item.progress >= 0) {
3474
+ const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
3475
+ style.background = hexToRgb(color, 0.3);
3476
+ style.borderRadius = '';
3477
+ contentProgressElement.style.background = color;
3478
+ }
3479
+ for (const key in style) {
3480
+ if (style.hasOwnProperty(key)) {
3481
+ contentElement.style[key] = style[key];
3482
+ }
3346
3483
  }
3347
3484
  }
3348
3485
  }
@@ -3351,10 +3488,10 @@ class NgxGanttBarComponent extends GanttItemUpper {
3351
3488
  }
3352
3489
  }
3353
3490
  NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
3354
- NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }, { propertyName: "handles", predicate: ["handle"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3491
+ NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }, { propertyName: "handles", predicate: ["handle"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"> </ng-template>\n</div>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
3355
3492
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
3356
3493
  type: Component,
3357
- args: [{ selector: 'ngx-gantt-bar,gantt-bar', providers: [GanttBarDrag], template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n" }]
3494
+ args: [{ selector: 'ngx-gantt-bar,gantt-bar', providers: [GanttBarDrag], template: "<div class=\"gantt-bar-layer\">\n <div class=\"drag-handles\">\n <ng-container *ngIf=\"item.draggable && ganttUpper.draggable\">\n <span class=\"handle\" #handle></span>\n <span class=\"handle\" #handle></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"> </ng-template>\n</div>\n" }]
3358
3495
  }], ctorParameters: function () {
3359
3496
  return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
3360
3497
  type: Inject,
@@ -3472,17 +3609,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3472
3609
  args: ['class.gantt-main-container']
3473
3610
  }] } });
3474
3611
 
3612
+ class GanttLoaderComponent {
3613
+ }
3614
+ GanttLoaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLoaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3615
+ GanttLoaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: GanttLoaderComponent, selector: "gantt-loader", host: { classAttribute: "gantt-loader gantt-loader-overlay" }, ngImport: i0, template: `
3616
+ <div class="gantt-loader-wrapper">
3617
+ <div class="gantt-loader-loading">
3618
+ <span class="gantt-loader-loading-spot"></span>
3619
+ </div>
3620
+ </div>
3621
+ `, isInline: true });
3622
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: GanttLoaderComponent, decorators: [{
3623
+ type: Component,
3624
+ args: [{
3625
+ selector: 'gantt-loader',
3626
+ template: `
3627
+ <div class="gantt-loader-wrapper">
3628
+ <div class="gantt-loader-loading">
3629
+ <span class="gantt-loader-loading-spot"></span>
3630
+ </div>
3631
+ </div>
3632
+ `,
3633
+ host: {
3634
+ class: 'gantt-loader gantt-loader-overlay'
3635
+ }
3636
+ }]
3637
+ }] });
3638
+
3475
3639
  class NgxGanttComponent extends GanttUpper {
3640
+ set loading(loading) {
3641
+ if (loading) {
3642
+ if (this.loadingDelay > 0) {
3643
+ this.loadingTimer = setTimeout(() => {
3644
+ this._loading = loading;
3645
+ this.cdr.markForCheck();
3646
+ }, this.loadingDelay);
3647
+ }
3648
+ else {
3649
+ this._loading = loading;
3650
+ }
3651
+ }
3652
+ else {
3653
+ clearTimeout(this.loadingTimer);
3654
+ this._loading = loading;
3655
+ }
3656
+ }
3657
+ get loading() {
3658
+ return this._loading;
3659
+ }
3476
3660
  constructor(elementRef, cdr, ngZone, printService, config) {
3477
3661
  super(elementRef, cdr, ngZone, config);
3478
3662
  this.printService = printService;
3479
3663
  this.maxLevel = 2;
3664
+ this.loadingDelay = 0;
3480
3665
  this.linkDragStarted = new EventEmitter();
3481
3666
  this.linkDragEnded = new EventEmitter();
3482
3667
  this.lineClick = new EventEmitter();
3483
3668
  this.selectedChange = new EventEmitter();
3484
3669
  this.flatData = [];
3485
3670
  this.renderData = [];
3671
+ this._loading = false;
3486
3672
  this.computeAllRefs = false;
3487
3673
  }
3488
3674
  ngOnInit() {
@@ -3642,7 +3828,7 @@ class NgxGanttComponent extends GanttUpper {
3642
3828
  }
3643
3829
  }
3644
3830
  NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GanttPrintService, optional: true }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
3645
- NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3831
+ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable", loading: "loading", loadingDelay: "loadingDelay" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick", selectedChange: "selectedChange" }, providers: [
3646
3832
  {
3647
3833
  provide: GANTT_UPPER_TOKEN,
3648
3834
  useExisting: NgxGanttComponent
@@ -3651,7 +3837,7 @@ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", vers
3651
3837
  provide: GANTT_ABSTRACT_TOKEN,
3652
3838
  useExisting: forwardRef(() => NgxGanttComponent)
3653
3839
  }
3654
- ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], viewQueries: [{ propertyName: "ganttRoot", first: true, predicate: ["ganttRoot"], descendants: true }, { propertyName: "virtualScroll", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n", dependencies: [{ kind: "directive", type: i2$1.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i2$1.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i2$1.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: ["columns"] }, { kind: "component", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: ["renderData", "flatData", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate", "draggable", "dropEnterPredicate"], outputs: ["dragDropped", "itemClick"] }, { kind: "component", type: GanttMainComponent, selector: "gantt-main", inputs: ["renderData", "flatData", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3840
+ ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], viewQueries: [{ propertyName: "ganttRoot", first: true, predicate: ["ganttRoot"], descendants: true }, { propertyName: "virtualScroll", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n <gantt-loader *ngIf=\"loading\"></gantt-loader>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\" [style.width.px]=\"tableHeader.tableWidth + 1\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i3.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i3.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "component", type: GanttTableHeaderComponent, selector: "gantt-table-header", inputs: ["columns"] }, { kind: "component", type: GanttTableBodyComponent, selector: "gantt-table-body", inputs: ["renderData", "flatData", "columns", "groupTemplate", "emptyTemplate", "rowBeforeTemplate", "rowAfterTemplate", "draggable", "dropEnterPredicate"], outputs: ["dragDropped", "itemClick"] }, { kind: "component", type: GanttMainComponent, selector: "gantt-main", inputs: ["renderData", "flatData", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }, { kind: "component", type: GanttCalendarHeaderComponent, selector: "gantt-calendar-header" }, { kind: "component", type: GanttCalendarGridComponent, selector: "gantt-calendar-grid" }, { kind: "component", type: GanttLoaderComponent, selector: "gantt-loader" }, { kind: "component", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }, { kind: "component", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
3655
3841
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: NgxGanttComponent, decorators: [{
3656
3842
  type: Component,
3657
3843
  args: [{ selector: 'ngx-gantt', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
@@ -3663,7 +3849,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3663
3849
  provide: GANTT_ABSTRACT_TOKEN,
3664
3850
  useExisting: forwardRef(() => NgxGanttComponent)
3665
3851
  }
3666
- ], template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n" }]
3852
+ ], template: "<ngx-gantt-root #ganttRoot>\n <div class=\"gantt-header\">\n <gantt-table-header #tableHeader [columns]=\"columns\"></gantt-table-header>\n <div class=\"gantt-container-header\">\n <gantt-calendar-header></gantt-calendar-header>\n </div>\n </div>\n <gantt-loader *ngIf=\"loading\"></gantt-loader>\n\n <cdk-virtual-scroll-viewport\n class=\"gantt-virtual-scroll-viewport\"\n [itemSize]=\"styles.lineHeight\"\n [minBufferPx]=\"styles.lineHeight * 10\"\n [maxBufferPx]=\"styles.lineHeight * 20\"\n >\n <ng-container *cdkVirtualFor=\"let item of flatData; trackBy: trackBy\"></ng-container>\n <div class=\"gantt-side\" [style.width.px]=\"tableHeader.tableWidth + 1\">\n <div class=\"gantt-side-container\">\n <div class=\"gantt-table\">\n <gantt-table-body\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [columns]=\"columns\"\n [groupTemplate]=\"groupTemplate\"\n [emptyTemplate]=\"tableEmptyTemplate\"\n [rowBeforeTemplate]=\"table?.rowBeforeTemplate\"\n [rowAfterTemplate]=\"table?.rowAfterTemplate\"\n [draggable]=\"table.draggable\"\n [dropEnterPredicate]=\"table.dropEnterPredicate\"\n (dragDropped)=\"table.dragDropped.emit($event)\"\n (itemClick)=\"selectItem($event)\"\n ></gantt-table-body>\n </div>\n </div>\n </div>\n\n <div class=\"gantt-container\">\n <gantt-calendar-grid></gantt-calendar-grid>\n <div class=\"gantt-main\">\n <gantt-main\n [flatData]=\"flatData\"\n [renderData]=\"renderData\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </div>\n </div>\n </cdk-virtual-scroll-viewport>\n\n <gantt-drag-backdrop [style.left.px]=\"tableHeader.tableWidth + 1\"></gantt-drag-backdrop>\n</ngx-gantt-root>\n" }]
3667
3853
  }], ctorParameters: function () {
3668
3854
  return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: GanttPrintService, decorators: [{
3669
3855
  type: Optional
@@ -3679,6 +3865,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3679
3865
  type: Input
3680
3866
  }], linkable: [{
3681
3867
  type: Input
3868
+ }], loading: [{
3869
+ type: Input
3870
+ }], loadingDelay: [{
3871
+ type: Input
3682
3872
  }], linkDragStarted: [{
3683
3873
  type: Output
3684
3874
  }], linkDragEnded: [{
@@ -3718,6 +3908,7 @@ NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
3718
3908
  GanttCalendarHeaderComponent,
3719
3909
  GanttCalendarGridComponent,
3720
3910
  GanttLinksComponent,
3911
+ GanttLoaderComponent,
3721
3912
  NgxGanttBarComponent,
3722
3913
  GanttIconComponent,
3723
3914
  GanttDragBackdropComponent,
@@ -3768,6 +3959,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3768
3959
  GanttCalendarHeaderComponent,
3769
3960
  GanttCalendarGridComponent,
3770
3961
  GanttLinksComponent,
3962
+ GanttLoaderComponent,
3771
3963
  NgxGanttBarComponent,
3772
3964
  GanttIconComponent,
3773
3965
  GanttDragBackdropComponent,
@@ -3797,5 +3989,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
3797
3989
  * Generated bundle index. Do not edit.
3798
3990
  */
3799
3991
 
3800
- export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttBaselineItemInternal, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLinkLineType, GanttLinkType, GanttLoadOnScrollEvent, GanttPrintService, GanttSelectedEvent, GanttTableDragDroppedEvent, GanttTableDragEnterPredicateContext, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, LinkColors, NgxGanttBarComponent, NgxGanttBaselineComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, NgxGanttToolbarComponent, defaultConfig, ganttViews, primaryDatePointTop, registerView, secondaryDatePointTop };
3992
+ export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttBaselineItemInternal, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLinkLineType, GanttLinkType, GanttLoadOnScrollEvent, GanttLoaderComponent, GanttPrintService, GanttSelectedEvent, GanttTableDragDroppedEvent, GanttTableDragEnterPredicateContext, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, LinkColors, NgxGanttBarComponent, NgxGanttBaselineComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, NgxGanttToolbarComponent, defaultConfig, ganttViews, primaryDatePointTop, registerView, secondaryDatePointTop };
3801
3993
  //# sourceMappingURL=worktile-gantt.mjs.map