+
NgxGantt 导出了 ngx-gantt-root、ngx-gantt-bar
@@ -7,7 +7,7 @@
下面示例实现了任务分组的展示,并且将每个分组下任务按时间维度打平展示。
-
@@ -19,6 +19,7 @@
[groups]="groups"
[viewType]="options.viewType"
[draggable]="options.draggable"
+ [restrictToBounds]="false"
[styles]="options.styles"
>
diff --git a/packages/gantt/src/components/bar/bar-drag.ts b/packages/gantt/src/components/bar/bar-drag.ts
index 503b075d..a97edef8 100644
--- a/packages/gantt/src/components/bar/bar-drag.ts
+++ b/packages/gantt/src/components/bar/bar-drag.ts
@@ -147,8 +147,10 @@ export class GanttBarDrag implements OnDestroy {
private createBarDrag() {
const dragRef = this.createDragRef(this.barElement);
dragRef.lockAxis = 'x';
- dragRef.withBoundaryElement(this.dom.mainItems as HTMLElement);
- dragRef.started.subscribe(() => {
+ if (this.ganttUpper.restrictToBounds) {
+ dragRef.withBoundaryElement(this.dom.mainItems as HTMLElement);
+ }
+ dragRef.started.subscribe((event) => {
this.setDraggingStyles();
this.containerScrollLeft = this.dom.mainContainer.scrollLeft;
this.createDragScrollEvent(dragRef).subscribe(() => {
@@ -563,6 +565,9 @@ export class GanttBarDrag implements OnDestroy {
const itemEnd = end.getUnixTime();
const viewStart = this.ganttUpper.view.start.getUnixTime();
const viewEnd = this.ganttUpper.view.end.getUnixTime();
+ if (!this.ganttUpper.restrictToBounds) {
+ return true;
+ }
if (itemStart < viewStart || itemEnd > viewEnd) {
return false;
} else {
diff --git a/packages/gantt/src/gantt-upper.ts b/packages/gantt/src/gantt-upper.ts
index bee8665a..04b006aa 100644
--- a/packages/gantt/src/gantt-upper.ts
+++ b/packages/gantt/src/gantt-upper.ts
@@ -68,6 +68,8 @@ export abstract class GanttUpper implements OnChanges, OnInit, OnDestroy {
@Input() showToolbar = false;
+ @Input() restrictToBounds = true;
+
@Input() toolbarOptions: GanttToolbarOptions = {
viewTypes: [GanttViewType.day, GanttViewType.month, GanttViewType.year]
};