Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/core/Autosizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ const getFilteredChildren = (
const filtered: CoreNode[] = [];
while (children.length > 0) {
const id = children.pop()!;
const child = childMap.get(id)!;
filtered.push(child);
const child = childMap.get(id);
if (child !== undefined) {
filtered.push(child);
}
}
return filtered;
};
Expand Down
32 changes: 32 additions & 0 deletions src/core/CoreTextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ export class CoreTextNode extends CoreNode implements CoreTextNodeProps {

private _type: 'sdf' | 'canvas' = 'sdf'; // Default to SDF renderer

/**
* Only texts whose parent transform/layout depends on measured dimensions
* need eager layout to avoid an initial position jump.
*/
private requiresLayoutForInitialTransform(props: CoreTextNodeProps): boolean {
const parent = props.parent;
if (parent === null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are already doing a parent is null check on the prior if check:
(props.forceLoad === true || props.parent !== null) &&

return false;
}

if (
parent.mountX !== 0 ||
parent.mountY !== 0 ||
parent.pivotX !== 0.5 ||
parent.pivotY !== 0.5
) {
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we returning true when the mount and pivot is being set?

}

Comment on lines +90 to +98
return parent.autosizer !== null || parent.parentAutosizer !== null;
}

constructor(
stage: Stage,
props: CoreTextNodeProps,
Expand All @@ -92,6 +114,16 @@ export class CoreTextNode extends CoreNode implements CoreTextNodeProps {
this.textProps = props;
this._containType = TextConstraint[props.contain];

if (
(props.forceLoad === true || props.parent !== null) &&
this.requiresLayoutForInitialTransform(props) === true &&
this.fontHandler.isFontLoaded(this.textProps.fontFamily) === true
) {
const resp = this.textRenderer.renderText(this.textProps);
this.handleRenderResult(resp);
this._layoutGenerated = true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only downside to this is it will also always render text+layouting even if the text is not in visible bounds or is alpha'd out

you may potentially be generating a lot of text that isnt even required to be rendered, maybe calling allowTextGeneration() would help avoid that?

Comment on lines +117 to +125
Comment on lines +117 to +125

this.setUpdateType(UpdateType.All);
}

Expand Down
Loading