Skip to content

Commit

Permalink
fix: fix drag style
Browse files Browse the repository at this point in the history
  • Loading branch information
HandsomeButterball committed Aug 2, 2023
1 parent 466b9c2 commit 1d3312d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
14 changes: 5 additions & 9 deletions packages/gantt/src/components/bar/bar-drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ export class GanttBarDrag implements OnDestroy {
});
}
} else {
if (!this.dragContainer.draggingItem) {
this.barElement.classList.add(activeClass);
}
this.barElement.classList.add(activeClass);
}
});

Expand Down Expand Up @@ -161,7 +159,7 @@ export class GanttBarDrag implements OnDestroy {
this.barDragMove();
}
});
this.dragContainer.emitDragStarted(this.item.origin);
this.dragContainer.dragStarted.emit({ item: this.item.origin });
});

dragRef.moved.subscribe((event) => {
Expand All @@ -185,7 +183,7 @@ export class GanttBarDrag implements OnDestroy {
x: this.ganttUpper.view.getXPointByDate(this.item.start),
y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
});
this.dragContainer.emitDragEnded(this.item.origin);
this.dragContainer.dragEnded.emit({ item: this.item.origin });
});
this.barDragRef = dragRef;

Expand Down Expand Up @@ -221,7 +219,7 @@ export class GanttBarDrag implements OnDestroy {
}
}
});
this.dragContainer.emitDragStarted(this.item.origin);
this.dragContainer.dragStarted.emit({ item: this.item.origin });
});

dragRef.moved.subscribe((event) => {
Expand Down Expand Up @@ -251,7 +249,7 @@ export class GanttBarDrag implements OnDestroy {
x: this.ganttUpper.view.getXPointByDate(this.item.start),
y: (this.ganttUpper.styles.lineHeight - this.ganttUpper.styles.barHeight) / 2 - 1
});
this.dragContainer.emitDragEnded(this.item.origin);
this.dragContainer.dragEnded.emit({ item: this.item.origin });
});
dragRefs.push(dragRef);
});
Expand Down Expand Up @@ -350,12 +348,10 @@ export class GanttBarDrag implements OnDestroy {
}

private setDraggingStyles() {
this.barElement.style.pointerEvents = 'none';
this.barElement.classList.add('gantt-bar-draggable-drag');
}

private clearDraggingStyles() {
this.barElement.style.pointerEvents = '';
this.barElement.classList.remove('gantt-bar-draggable-drag');
}

Expand Down
4 changes: 4 additions & 0 deletions packages/gantt/src/components/bar/bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export class NgxGanttBarComponent extends GanttItemUpper implements OnInit, Afte

override ngOnInit() {
super.ngOnInit();
this.dragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
this.elementRef.nativeElement.style.pointerEvents = 'none';
});
this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
this.elementRef.nativeElement.style.pointerEvents = '';
this.setContentBackground();
});
}
Expand Down
14 changes: 1 addition & 13 deletions packages/gantt/src/gantt-drag-container.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, EventEmitter, Inject } from '@angular/core';
import { GanttLinkType } from './class';
import { GanttDragEvent, GanttLinkDragEvent } from './class/event';
import { GanttItem, GanttItemInternal } from './class/item';
import { GanttItemInternal } from './class/item';
import { GanttUpper, GANTT_UPPER_TOKEN } from './gantt-upper';

function getDependencyType(path: LinkDragPath, dependencyTypes: GanttLinkType[]): GanttLinkType {
Expand Down Expand Up @@ -47,24 +47,12 @@ export class GanttDragContainer {

linkDragEnded = new EventEmitter<GanttLinkDragEvent>();

draggingItem: GanttItem;

linkDraggingId: string;

linkDragPath: LinkDragPath = { from: null, to: null };

constructor(@Inject(GANTT_UPPER_TOKEN) public ganttUpper: GanttUpper) {}

emitDragStarted(item: GanttItem) {
this.draggingItem = item;
this.dragStarted.emit({ item });
}

emitDragEnded(item: GanttItem) {
this.draggingItem = null;
this.dragEnded.emit({ item });
}

emitLinkDragStarted(from: LinkDragPosition) {
this.linkDraggingId = from.item.id;
this.linkDragPath.from = from;
Expand Down

0 comments on commit 1d3312d

Please sign in to comment.