Skip to content

Commit ede3a79

Browse files
committed
Upd: 实现了双击删除连线
1 parent 8c5cbeb commit ede3a79

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/vf/flowgraph/interact/socket-hint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class SocketHint {
6767
}
6868

6969
move(mouse: Point): void {
70-
console.log('move', mouse)
70+
// console.log('move', mouse)
7171
let nearest = socket_pool.nearest_within(mouse, SocketHint.radis, false)
7272

7373
if (nearest !== undefined) {

src/vf/flowgraph/pool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class LinePool {
7979
this.lines.push(e)
8080
}
8181

82-
remote_line(e: Line): void {
82+
remove_line(e: Line): void {
8383
this.lines = this.lines.filter((el) => el.id !== e.id)
8484
}
8585

src/vf/type/line.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { flowgraph } from "../flowgraph/flowgraph"
2+
import { line_pool } from "../flowgraph/pool"
23
import { TricolorPreset } from "../preset/color"
34
import { appendChild } from "../util/appendChild"
45
import { Guid, root } from "../util/guid"
@@ -36,12 +37,19 @@ class Line {
3637
this.el.setAttribute('stroke-width', '5')
3738
this.el.setAttribute('fill', 'none')
3839
appendChild(flowgraph.el, this)
40+
41+
this.el.addEventListener('click', () => {
42+
line_pool.remove_line(this)
43+
this.destructor()
44+
})
45+
3946
this.display()
4047
}
4148

4249
destructor () {
4350
this.start.used = false
4451
this.end.used = false
52+
this.el.parentNode!.removeChild(this.el)
4553
}
4654

4755
display() {

0 commit comments

Comments
 (0)