From 4739ec94a22204526d3935a0af1a8950f911898d Mon Sep 17 00:00:00 2001 From: MissLixf <1090474924@qq.com> Date: Tue, 26 Mar 2024 10:32:40 +0800 Subject: [PATCH] fix(common): fix image with angle drag error #WIK-14971 --- .changeset/rotten-nails-tell.md | 5 +++++ packages/common/src/generators/image.generator.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/rotten-nails-tell.md diff --git a/.changeset/rotten-nails-tell.md b/.changeset/rotten-nails-tell.md new file mode 100644 index 000000000..734a84194 --- /dev/null +++ b/.changeset/rotten-nails-tell.md @@ -0,0 +1,5 @@ +--- +'@plait/common': patch +--- + +fix(common): fix image with angle drag error diff --git a/packages/common/src/generators/image.generator.ts b/packages/common/src/generators/image.generator.ts index 30f04110a..74d57a91a 100644 --- a/packages/common/src/generators/image.generator.ts +++ b/packages/common/src/generators/image.generator.ts @@ -5,6 +5,7 @@ import { RectangleClient, createForeignObject, createG, + setAngleForG, updateForeignObject } from '@plait/core'; import { Generator, GeneratorOptions } from './generator'; @@ -64,6 +65,7 @@ export class ImageGenerator extends Gener updateImage(nodeG: SVGGElement, previous: T, current: T) { if (previous !== current && this.componentRef) { this.componentRef.instance.imageItem = this.options.getImageItem(current); + this.componentRef.instance.element = current; this.componentRef!.instance.getRectangle = () => { return this.options.getRectangle(current); }; @@ -76,6 +78,9 @@ export class ImageGenerator extends Gener currentForeignObject.x, currentForeignObject.y ); + if (currentForeignObject && current.angle) { + setAngleForG(this.g!, RectangleClient.getCenterPoint(currentForeignObject), current.angle); + } // solve image lose on move node if (this.foreignObject.children.length === 0) { this.foreignObject.append(this.componentRef!.instance.nativeElement);