Skip to content

Commit

Permalink
fix: 修改ghost组件
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeard30 committed Mar 31, 2024
1 parent de95dcf commit 8f409c5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/app/components/widgets/ghost/ghost.widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { fromEvent, Subject, takeUntil } from 'rxjs';
selector: 'app-ghost',
standalone: true,
template: `
@if (cursor.status === CursorStatus.Dragging) {
@if (firstNode && cursor.status === CursorStatus.Dragging) {
<div class="{{ prefix }}" #containerRef>
<span style="white-space: nowrap">
<app-node-title-widget [node]="firstNode"></app-node-title-widget>
Expand Down Expand Up @@ -54,22 +54,20 @@ export class GhostWidget implements AfterViewInit, OnDestroy {
}

ngAfterViewInit(): void {
fromEvent(window, 'mousedown')
fromEvent(window, 'mousemove')
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
setTimeout(() => {
this.movingNodes = this.designer.findMovingNodes();
this.firstNode = this.movingNodes[0];
}, 100);
this.movingNodes = this.designer.findMovingNodes();
this.firstNode = this.movingNodes[0];
});

autorun(() => {
this.cdr.markForCheck();
this.cdr.detectChanges();
const transform = `perspective(1px) translate3d(${
this.cursor.position?.topClientX - 18
}px,${this.cursor.position?.topClientY - 12}px,0) scale(0.8)`;
if (!this.containerRef) return;

if (!this.firstNode) return;
this.containerRef.nativeElement.style.transform = transform;
});
}
Expand Down

0 comments on commit 8f409c5

Please sign in to comment.