-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
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
fix(core): 修复多选旋转的节点后进行移动时,节点位置异常问题 #2032
Conversation
移动后未更新 transform 导致旋转的节点位置异常。改成在 getMoveDistance 方法中更新 transform
|
相关 issue : #1794
|
也太酷了,我们看下 |
太赞了,看了一下没问题,马上就过! |
移动逻辑中,更新 transform 旋转矩阵只在 而多选时的移动是通过 这里的改动是将更新 重新理了下这里的解决方案,感觉可以再优化下。现在 |
@ZivvW |
@DymoneLewis 类似这样吧,提取移动逻辑,3个方法调用核心函数返回各自的值,后续要修改移动逻辑的时候不用在 3 个方法里都加一遍 @action moveCore(
deltaX: number,
deltaY: number,
isIgnoreRule = false,
): false | [number, number] {
const { isAllowMoveX, isAllowMoveY } = this.isAllowMoveByXORY(
deltaX,
deltaY,
isIgnoreRule,
)
if (!isAllowMoveX && !isAllowMoveY) return false
let moveX = 0
let moveY = 0
if (isAllowMoveX && deltaX) {
this.x = this.x + deltaX
this.text && this.moveText(deltaX, 0)
moveX = deltaX
}
if (isAllowMoveY && deltaY) {
this.y = this.y + deltaY
this.text && this.moveText(0, deltaY)
moveY = deltaY
}
// 更新x和y的同时也要更新对应的transform旋转矩阵(依赖x、y)
this.rotate = this._rotate
return [moveX, moveY]
}
@action move(deltaX: number, deltaY: number, isIgnoreRule = false): boolean {
return !!this.moveCore(deltaX, deltaY, isIgnoreRule)
}
@action getMoveDistance(
deltaX: number,
deltaY: number,
isIgnoreRule = false,
): [number, number] {
const moveResult = this.moveCore(deltaX, deltaY, isIgnoreRule)
if (!moveResult) return [0, 0]
return moveResult
}
@action moveTo(x: number, y: number, isIgnoreRule = false): boolean {
const deltaX = x - this.x
const deltaY = y - this.y
return this.move(deltaX, deltaY, isIgnoreRule)
} 另外目前代码中的 |
多选时的移动未更新 transform 导致旋转的节点位置异常。改成在 getMoveDistance 方法中更新 transform,统一处理所有移动逻辑
before:

after:
