We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
问题描述 / Describe the bug
图形成组后移动组,再解除成组后,成组图形恢复原位。理想情况应该是原地解除组合。
复现步骤 / To Reproduce
期望行为 / Expected behavior
截图 / Screenshots
桌面设备信息 / Desktop (please complete the following information):
移动设备信息 / Smartphone (please complete the following information):
附加上下文 / Additional context
The text was updated successfully, but these errors were encountered:
在源代码中对于将组内组件移动到父级的操作并没有对组内成员进行任何变换操作,这导致组内成员的变换矩阵依然是加入组之前的。
根据调试发现,将图形添加到组内,对组进行平移变换的时候并不会改变组内成员的变换信息。
成组前:
成组后:
根据对比发现成组后,对组的变换并不影响组内成员的变换信息。
原本我是想通过矩阵乘法将组的变换应用到组内成员,从而计算出组内成员的最新变换信息,再将计算出来的变换信息应用到组内成员。
后来发现Konva中Node的getAbsoluteTransform正是图形对于某个坐标系的真实变换,所以解除组时我们只需要通过这个函数来获取组内成员的真实变换,然后再将真实变换应用回组。
Konva
Node
getAbsoluteTransform
public _decomposeGroup(group: Konva.Group): KonvaNode[] { const parent = group.getParent() ?? this.mainLayer; const resolve = [...group.getChildren()].map((child) => { const { x, y, scaleX, scaleY, rotation } = child.getAbsoluteTransform(parent).copy().decompose(); child.moveTo(parent); child.position({ x, y }); child.scale({ x: scaleX, y: scaleY }); child.rotation(rotation); return child; }); this._remove(group); return resolve; }
Sorry, something went wrong.
JessYan0913
Successfully merging a pull request may close this issue.
Bug Report / 缺陷报告
问题描述 / Describe the bug
图形成组后移动组,再解除成组后,成组图形恢复原位。理想情况应该是原地解除组合。
复现步骤 / To Reproduce
期望行为 / Expected behavior
截图 / Screenshots
桌面设备信息 / Desktop (please complete the following information):
移动设备信息 / Smartphone (please complete the following information):
附加上下文 / Additional context
The text was updated successfully, but these errors were encountered: