Skip to content

Commit

Permalink
Optimize custom object layouting in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H committed Oct 21, 2024
1 parent 0383f8a commit b6da9d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ export const getLayoutedRenderedInstance = <T: ChildRenderedInstance>(
// Make sure to give a custom size to the instances only when it's necessary.
// Some objects like TextObject may wrap text differently with a custom size.
if (
(parentScaleX === 1 && parentScaleY === 1) ||
(!leftEdgeAnchor && !rightEdgeAnchor && !topEdgeAnchor && !bottomEdgeAnchor)
(parentScaleX === 1 || (!leftEdgeAnchor && !rightEdgeAnchor)) &&
(parentScaleY === 1 || (!topEdgeAnchor && !bottomEdgeAnchor))
) {
layoutedInstance.x = initialInstance.getX();
layoutedInstance.y = initialInstance.getY();
Expand All @@ -381,6 +381,8 @@ export const getLayoutedRenderedInstance = <T: ChildRenderedInstance>(
const initialInstanceX = initialInstance.getX();
const initialInstanceWidth = initialInstance.hasCustomSize()
? initialInstance.getCustomWidth()
// The default width of Text object is dependent of the current wrapping width.
// It result in strange behaviors when text objects don't have a custom size.
: renderedInstance.getDefaultWidth();

if (parentScaleX === 1 || (!leftEdgeAnchor && !rightEdgeAnchor)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,14 @@ export default class RenderedTextInstance extends RenderedInstance {
}

getDefaultWidth() {
// The default width is dependent of the current wrapping width.
// You should avoid to use this value.
return this._pixiObject.width;
}

getDefaultHeight() {
// The default height is dependent of the current wrapping width.
// You should avoid to use this value.
return this._pixiObject.height;
}

Expand Down

0 comments on commit b6da9d5

Please sign in to comment.