Skip to content

Commit

Permalink
feat: 顶点控制器增加更新顶点功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Heng committed Jul 25, 2023
1 parent d4edca7 commit 19722ad
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/core/src/customs/polyline.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { fabric } from 'fabric';

export class Polyline extends fabric.Polyline {
private selectedControl: string | null = null;
private originalPoint: fabric.Point | null = null;

public onSelect(options: { e?: Event | undefined }): boolean {
const points = this.points ?? [];
this.controls = points.reduce<Record<string, fabric.Control>>(
Expand All @@ -18,6 +21,16 @@ export class Polyline extends fabric.Polyline {
)
);
},
actionHandler: (eventData, transformData, x, y) => {
// 更新点的位置
points[index].x = x;
points[index].y = y;
// 重新设置points
this.points = points;
// 更新坐标
this.setCoords();
return true;
},
});
return controls;
},
Expand Down

0 comments on commit 19722ad

Please sign in to comment.