Skip to content

Commit 19722ad

Browse files
author
Yan Heng
committed
feat: 顶点控制器增加更新顶点功能
1 parent d4edca7 commit 19722ad

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/core/src/customs/polyline.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { fabric } from 'fabric';
22

33
export class Polyline extends fabric.Polyline {
4+
private selectedControl: string | null = null;
5+
private originalPoint: fabric.Point | null = null;
6+
47
public onSelect(options: { e?: Event | undefined }): boolean {
58
const points = this.points ?? [];
69
this.controls = points.reduce<Record<string, fabric.Control>>(
@@ -18,6 +21,16 @@ export class Polyline extends fabric.Polyline {
1821
)
1922
);
2023
},
24+
actionHandler: (eventData, transformData, x, y) => {
25+
// 更新点的位置
26+
points[index].x = x;
27+
points[index].y = y;
28+
// 重新设置points
29+
this.points = points;
30+
// 更新坐标
31+
this.setCoords();
32+
return true;
33+
},
2134
});
2235
return controls;
2336
},

0 commit comments

Comments
 (0)