-
-
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
refactor(): Change how LayoutManager handles restoring groups #9522
Conversation
Build Stats
|
f617995
to
9d4887c
Compare
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 good work!
I thought there was an option to declare a private constructor overload but TS doesn't allow mixing private/public for a single signature.
What if we pass a value in the layoutManager option instead?
Can we also rename |
I suggest we subclass FitContentLayout export class FitContentLayout2 extends FitContentLayout {
shouldPerformLayout(context: StrictLayoutContext) {
return context.type !== LAYOUT_TYPE_INITIALIZATION;
}
} This seems to me the best approach. It is hidden from the dev and can't be used (we do not need to expose this class) and it subscribes the objects in initializion as it should |
However it doesn't respect overrides if someone wants to override |
so actually all we need is to pass an option to FitContentLayout in fromObject export class FitContentLayout {
performInitializationLayout = true
shouldPerformLayout(context: StrictLayoutContext) {
return context.type !== LAYOUT_TYPE_INITIALIZATION || this.performInitializationLayout;
}
} And then in |
i would like the layout manager to no have to deal with fromObject quirks. |
something like this example commit here: |
something like that can work |
I want to see how everything looks like when group can be properly serialized with the constructor and the layout managers in the serialization process. Then if someone really need anyhing more than fit-content, fixed size and clip-path layouts will eventually complain or silently find a solution |
The change with the class has been done, i don't plan to touch anything else if not requested changes. @ShaMan123 |
@ShaMan123 do you have time to review? |
Not today |
@ShaMan123 any chance we can move forward with this and proceed to finish the layout manager? |
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.
Looking good apart from a test I don't understand
layoutManager: new RespectfulLayoutManager(), | ||
}); | ||
group.layoutManager = new LayoutManager(); | ||
group.setCoords(); |
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.
do we need this?
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 because is the layoutManager that is doing setCoords for the group initialization.
It doesn't have to, but is doing it, it changes width and height or top and left, so it make sense it also calls setCoords.
If the the layoutManager is a no-op then a manual call to setCoords is necessary
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.
Co-authored-by: Shachar <34343793+ShaMan123@users.noreply.github.com>
Ok off to the second part then, restoring fromObject. |
Motivation
Trying to remove the special boolean for the constructor for objects relative to center.
The issue with restoring an object from data is that the data is correct, and so the layout operation is not needed at all.
Instead of having logic inside the layout manager to do calculation but don't mutate objects or the position, we can just skip the layout manager all together.
I wish there was a way make that option not usable by a dev but i couldn't think of a simple solution.
TODO:
FOLLOWUP:
proper layout manager serialization and restore
Description
Changes
Gist
In Action