From d75e16db8261330c944ebf2aee6be60e372d68ff Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 16 Jan 2024 17:17:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E6=8F=92=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=9B=B4=E5=A4=9A=E7=9A=84=E7=A7=BB=E5=8A=A8=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/index.js | 7 +++++++ lib/plugins/CopyPlugin.d.ts | 8 ++++++-- package.json | 2 +- src/plugins/CopyPlugin.ts | 17 +++++++++++++++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2fe1080..0497a97 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1185,6 +1185,13 @@ class GraphicCopyPlugin { this.container.position.y = dy; } } + for (let i = 0; i < this.graphicControlers.length; i++) { + if (this.graphicControlers[i].moveLimitOption?.moveLimitName == + this.moveLimit) { + this.graphicControlers[i].moveLimitOption?.moveLimit(e); + } + break; + } } onFinish() { console.log('复制确认'); diff --git a/lib/plugins/CopyPlugin.d.ts b/lib/plugins/CopyPlugin.d.ts index f117769..c487fad 100644 --- a/lib/plugins/CopyPlugin.d.ts +++ b/lib/plugins/CopyPlugin.d.ts @@ -5,6 +5,10 @@ import { KeyListener } from './KeyboardPlugin'; interface GraphicControler { controlerList: KeyListener[]; check: () => boolean; + moveLimitOption?: { + moveLimitName: string; + moveLimit: (e: FederatedPointerEvent) => void; + }; } /** * 图形复制插件 @@ -17,9 +21,9 @@ export declare class GraphicCopyPlugin { copys: JlGraphic[]; start?: Point; running: boolean; - moveLimit?: 'x' | 'y'; + moveLimit?: string; constructor(scene: IGraphicScene); - updateMoveLimit(limit?: 'x' | 'y'): void; + updateMoveLimit(limit?: string): void; init(): void; addGraphicControlers(graphicControlers: GraphicControler[]): void; clear(): void; diff --git a/package.json b/package.json index 5250347..81147b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "graphic-pixi", - "version": "0.1.6", + "version": "0.1.8", "description": "基于pixijs的图形应用、绘制应用框架", "productName": "Graphic-pixi", "author": "walker ", diff --git a/src/plugins/CopyPlugin.ts b/src/plugins/CopyPlugin.ts index 695f245..e6910c9 100644 --- a/src/plugins/CopyPlugin.ts +++ b/src/plugins/CopyPlugin.ts @@ -6,6 +6,10 @@ import { KeyListener } from './KeyboardPlugin'; interface GraphicControler { controlerList: KeyListener[]; check: () => boolean; + moveLimitOption?: { + moveLimitName: string; + moveLimit: (e: FederatedPointerEvent) => void; + }; } /** @@ -19,7 +23,7 @@ export class GraphicCopyPlugin { copys: JlGraphic[]; start?: Point; running = false; - moveLimit?: 'x' | 'y'; + moveLimit?: string; constructor(scene: IGraphicScene) { this.scene = scene; this.container = new Container(); @@ -57,7 +61,7 @@ export class GraphicCopyPlugin { ); } - updateMoveLimit(limit?: 'x' | 'y'): void { + updateMoveLimit(limit?: string): void { if (this.moveLimit === limit) { this.moveLimit = undefined; } else { @@ -136,6 +140,15 @@ export class GraphicCopyPlugin { this.container.position.y = dy; } } + for (let i = 0; i < this.graphicControlers.length; i++) { + if ( + this.graphicControlers[i].moveLimitOption?.moveLimitName == + this.moveLimit + ) { + this.graphicControlers[i].moveLimitOption?.moveLimit(e); + } + break; + } } onFinish(): void {