-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(demo): simulate db click event and prevent default action fo…
…r pointerUp in graph-viz demo (#955)
- Loading branch information
1 parent
fe3603a
commit b81d2b3
Showing
3 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Component, ElementRef, inject, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; | ||
import { | ||
PlaitBoard, | ||
toViewBoxPoint, | ||
toHostPoint | ||
} from '@plait/core'; | ||
@Component({ | ||
selector: 'debug-point-display', | ||
template:``, | ||
standalone: true, | ||
imports: [], | ||
host: { | ||
'style': 'position: absolute;top:0;left:0;' | ||
} | ||
}) | ||
export class DebugPointDisplayComponent implements OnInit, OnChanges { | ||
@Input() | ||
board?: PlaitBoard; | ||
|
||
elementRef: ElementRef<HTMLElement> = inject(ElementRef<HTMLElement>); | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): void {} | ||
|
||
ngOnChanges(changes: SimpleChanges): void { | ||
if (changes['board'] && this.board) { | ||
const board = this.board as PlaitBoard; | ||
const { pointerMove } = board; | ||
board.pointerMove = e => { | ||
pointerMove(e); | ||
const point = toViewBoxPoint(board, toHostPoint(board, e.x, e.y)); | ||
this.elementRef.nativeElement.innerHTML = `${point[0]},${point[1]}`; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
<plait-board [plaitPlugins]="plugins" [plaitValue]="value" [plaitViewport]="viewport" [plaitTheme]="theme" | ||
[plaitOptions]="options" > | ||
<plait-board | ||
[plaitPlugins]="plugins" | ||
[plaitValue]="value" | ||
[plaitViewport]="viewport" | ||
[plaitTheme]="theme" | ||
[plaitOptions]="options" | ||
(onChange)="onChange($event)" | ||
(plaitBoardInitialized)="afterBoardInitialized($event)" | ||
> | ||
<app-zoom-toolbar></app-zoom-toolbar> | ||
</plait-board> | ||
<!-- @if (board) { | ||
<debug-point-display [board]="board"></debug-point-display> | ||
} --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters