-
-
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
update(AligningGuidelines): Fix some bugs and add custom features. #10120
base: master
Are you sure you want to change the base?
update(AligningGuidelines): Fix some bugs and add custom features. #10120
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
2024-09-02.14.23.03.mov |
5e1acc1
to
326e756
Compare
326e756
to
9523d69
Compare
When the angle of the operated graphic is not 0, there is a bug with the 4-corner scaling alignment. I will solve it at noon tomorrow. |
fixed 2024-09-11.10.19.10.mov
|
In practical use, a common issue has been identified: when there are too many shapes, the problem of excessive reference line hits occurs because each shape is compared with the current shape. It is suggested to change the approach to count all points and use those points for judgment. (The same issue occurs in V5; if there are related requirements for V5, please refer to the modifications.) The following is a video comparison before and after the modifications. a.movb.mov |
I m sorry i didn't have time for this and i won't for a bit. |
Okay, I will take some time to write the test cases, while also adding the corresponding listener functions and disabling the relevant feature switches. |
@asturur |
// tr <-> tl、 bl <-> br、 mb <-> mt、 ml <-> mr | ||
if (target.flipX) corner = corner.replace('l', 'r').replace('r', 'l'); | ||
if (target.flipY) corner = corner.replace('t', 'b').replace('b', 't'); | ||
const coords = target.getCoords(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see properly but is this constant used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When executing the flip, its value becomes true, which is set internally by Fabric. The video below shows the bug that occurs when it is turned off.
2024-11-07.10.01.35.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that const coords = target.getCoords();
seems unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, it should be deleted.
|
||
// You can customize the return graphic, and the example will only compare it with sibling elements | ||
initAligningGuidelines(myCanvas, { | ||
getObjectsByTarget: function (target) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this PR and tried using this function to filter out objects that have properties isGridLine
on them
like if (!object.isGridLine) { set.add(object) }
but then no guidelines happened at all
was I using it wrong maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Smrtnyk
Can you provide a simple demo to reproduce your issue? This will help me locate the problem. Regarding this function, if customized, it means that when moving the target element, it only processes the reference line for the graphical representation of the return value
The input parameter of this function is the current shape being operated on, not a loop representing all shapes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is what I tried
initAligningGuidelines(this.canvas, {
getObjectsByTarget: () => {
const set = new Set<FabricObject>();
for (const obj of this.canvas.getObjects()) {
if (obj.isGridLine) {
continue;
}
set.add(obj);
}
return set;
},
});
I have a grid that I toggle, used as a helper when adding shapes
for aligning guidelines I want to ignore all lines in that grid
and I thought I can ignore them if I don't add them to the set that is being returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Smrtnyk
I wrote the custom code according to your method and found that it works. You can compare it with the demo to see where the differences are.
custom demo
2024-11-08.10.37.59.mov
I have downloaded locally this PR and use it in the project, it is better than the current version for my needs |
I have been testing this patch for a while now in production in my fabric app. |
Resolve the issue where when the user scales using scaleX, scaleY is not updated simultaneously. The same applies to scaleY.