From 19722ad906c33a9b6c7591bdcd89ca5f48c285ef Mon Sep 17 00:00:00 2001 From: Yan Heng Date: Tue, 25 Jul 2023 15:16:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B6=E7=82=B9=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0=E9=A1=B6=E7=82=B9?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/customs/polyline.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/core/src/customs/polyline.ts b/packages/core/src/customs/polyline.ts index 95e07dc6..6bb57055 100644 --- a/packages/core/src/customs/polyline.ts +++ b/packages/core/src/customs/polyline.ts @@ -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>( @@ -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; },