重新打包

This commit is contained in:
joylink_zhaoerwei 2024-01-15 13:55:25 +08:00
parent b5f2a9c1df
commit dd9c5b528a
3 changed files with 14 additions and 2 deletions

2
lib/index.d.ts vendored
View File

@ -1,4 +1,4 @@
/// <reference path="../global.d.ts" /> /// <reference types="global" />
export * as GraphicsExtras from '@pixi/graphics-extras'; export * as GraphicsExtras from '@pixi/graphics-extras';
export * from './app'; export * from './app';
export * from './core'; export * from './core';

View File

@ -1068,6 +1068,7 @@ class GraphicCopyPlugin {
container; container;
scene; scene;
keyListeners; keyListeners;
graphicKeyListenercMap;
copys; copys;
start; start;
running = false; running = false;
@ -1075,6 +1076,7 @@ class GraphicCopyPlugin {
constructor(scene) { constructor(scene) {
this.scene = scene; this.scene = scene;
this.container = new Container(); this.container = new Container();
this.graphicKeyListenercMap = new Map();
this.copys = []; this.copys = [];
this.keyListeners = []; this.keyListeners = [];
this.keyListeners.push(new KeyListener({ this.keyListeners.push(new KeyListener({
@ -1130,6 +1132,10 @@ class GraphicCopyPlugin {
this.container.addChild(clone); this.container.addChild(clone);
clone.repaint(); clone.repaint();
}); });
const addGraphicTypeKeyListener = this.graphicKeyListenercMap.get(app.selectedGraphics[0].type);
if (addGraphicTypeKeyListener) {
this.keyListeners.push(...addGraphicTypeKeyListener);
}
this.scene.canvas.on('mousemove', this.onPointerMove, this); this.scene.canvas.on('mousemove', this.onPointerMove, this);
this.scene.canvas.on('mouseup', this.onFinish, this); this.scene.canvas.on('mouseup', this.onFinish, this);
this.scene.canvas.on('rightup', this.cancle, this); this.scene.canvas.on('rightup', this.cancle, this);
@ -1150,6 +1156,7 @@ class GraphicCopyPlugin {
this.keyListeners.forEach((kl) => { this.keyListeners.forEach((kl) => {
this.scene.app.removeKeyboardListener(kl); this.scene.app.removeKeyboardListener(kl);
}); });
this.keyListeners = this.keyListeners.splice(0, 3);
} }
onPointerMove(e) { onPointerMove(e) {
const cp = this.scene.toCanvasCoordinates(e.global); const cp = this.scene.toCanvasCoordinates(e.global);
@ -1182,10 +1189,13 @@ class GraphicCopyPlugin {
g.position.x += this.container.position.x; g.position.x += this.container.position.x;
g.position.y += this.container.position.y; g.position.y += this.container.position.y;
}); });
this.saveCopyGraphic();
this.clear();
}
saveCopyGraphic() {
this.scene.app.addGraphicAndRecord(...this.copys); this.scene.app.addGraphicAndRecord(...this.copys);
this.scene.detectRelations(); this.scene.detectRelations();
this.scene.updateSelected(...this.copys); this.scene.updateSelected(...this.copys);
this.clear();
} }
cancle() { cancle() {
console.log('复制操作取消'); console.log('复制操作取消');

View File

@ -9,6 +9,7 @@ export declare class GraphicCopyPlugin {
container: Container; container: Container;
scene: IGraphicScene; scene: IGraphicScene;
keyListeners: KeyListener[]; keyListeners: KeyListener[];
graphicKeyListenercMap: Map<string, KeyListener[]>;
copys: JlGraphic[]; copys: JlGraphic[];
start?: Point; start?: Point;
running: boolean; running: boolean;
@ -19,5 +20,6 @@ export declare class GraphicCopyPlugin {
clear(): void; clear(): void;
onPointerMove(e: FederatedPointerEvent): void; onPointerMove(e: FederatedPointerEvent): void;
onFinish(): void; onFinish(): void;
saveCopyGraphic(): void;
cancle(): void; cancle(): void;
} }