-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Bug]: Flip object inside group whose interactive is true got wrong behavior. #9801
Comments
i ll look into this tomorrow morning |
Ok i looked at this, i have some code changes that improve the situation but do not fix it entirely. |
This could be a reasonable change that fix the issue and is very scoped to this case. positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),
startMatrix = multiplyTransformMatrices(vpt, positionMatrix),
+ transformOptions = this.group
+ ? qrDecompose(this.calcTransformMatrix())
+ : undefined,
finalMatrix = multiplyTransformMatrices(startMatrix, [
1 / vpt[0],
0,
@@ -245,14 +248,17 @@ export class InteractiveFabricObject<
0,
0,
]),
- transformOptions = this.group
- ? qrDecompose(this.calcTransformMatrix())
- : undefined,
- dim = this._calculateCurrentDimensions(transformOptions),
- coords: Record<string, TOCoord> = {};
+ { x, y } = this._calculateCurrentDimensions(transformOptions),
+ coords: Record<string, TOCoord> = {},
+ correctedDims = new Point(Math.abs(x), Math.abs(y));
this.forEachControl((control, key) => {
- const position = control.positionHandler(dim, finalMatrix, this, control);
+ const position = control.positionHandler(
+ correctedDims,
+ finalMatrix,
+ this,
+ control
+ );
// coords[key] are sometimes used as points. Those are points to which we add
// the property corner and touchCorner from `_calcCornerCoords`.
// don't remove this assign for an object spread. |
Except this breaks with padding |
Ok we have a PR for this |
@asturur Thanks so much to take time to look into this issue and fix it. E.g.:
I want to know rectangle1 absolute position (left, top) and dimensions (width, height). is there a way I can get them without remove rect1 from group? Does below calculation work? Thanks in advance. |
Assuming you are not using strokeUniform, rect.getCoords() should give you all you need, taking in account for group transform
If you are not using a rect or you want know a specific point of a shape where it is in the scene coordinates, you have to calculate where that point is located respect to the center and get that point trasnformed. For example, the center of a shape inside any nested group, in scene coordinates is always at:
a point that is 5 unit left and 4 unit lower than the center ( usually pixels ) will be:
calcTransforMatrix() take in account your shape scale and rotation, and the group properties. If you have already accounted for the shape transformation and you want to know only the group transfromation you can use shape.parent.calcTransformMatrix() to get the transform done. |
@asturur Thanks so much for the detail answer. :):) May I say, the shape.calcTransformMatrix() will consider not only its parent but also its group properties, right? (I read it from the code and the test seems like this). Why I continue to use this function because I want to get the scaleX, scaleY also. |
CheckList
Version
6.0.0-beta20
In What environments are you experiencing the problem?
Microsoft Edge
Node Version (if applicable)
None
Link To Reproduction
https://jsfiddle.net/ritali4912/x6nd5e7k/11/
Steps To Reproduce
There is a group whose subTargetCheck: true, interactive: true.
Then I flip one of its children, but got strange behavior. It seems the control after flip are wrong.
Refer to the below gif.
Expected Behavior
The child object inside group can scale/flip as normal.
Actual Behavior
The child object seems got wrong controls after flip.
Error Message & Stack Trace
No response
The text was updated successfully, but these errors were encountered: