Skip to content

Conversation

@wouterlucas
Copy link
Contributor

Add autosize to a node to dynamically update its size based on children's matrix3d.

  • Reuse of autosize property
  • If node has a texture, that behavior will be prioritized (to not break existing behavior)
  • If node does not have a texture, w/h are automatically adjusted to envelop children

notes:

  • Does not grow "backward" so only beyond its own x,y anchor left + down
  • Although optimized, this is not "for free" as it will involve additional calculations

PR includes unit tests and VRT testcase.

Useful for Touch/Point usecases where you want the parent to be clickable and may provide utility for flexbox usage.

image

w: number,
h: number,
) => {
if (carryOver === true) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

what does carryOver do/mean?

Copy link
Collaborator

Choose a reason for hiding this comment

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

forget about this, I removed it and changed a bit of logic to avoid unnessecary calcs.

Copy link
Contributor Author

@wouterlucas wouterlucas left a comment

Choose a reason for hiding this comment

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

nice - looks good, minor remarks.

it would make sense to test this with some large deeply nested child trees. Just to profile what the impact is of having a lot of children/deeply nested children when navigating around.

}
}

patch(node: CoreNode) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

would it be cheaper to go by ID only?

basically:

patch(id: number) {

since you're getting the entry anyway from the this.childMap, saves pushing a big node reference across.
Also entry isn't used further down - it would make that actually be used 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed

if (corner.y > maxY) maxY = corner.y;
}
}
this.flaggedChildren.length = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this does mean the array can be adjusted while we are in the for loop, correct?
would it be better to copy the contents and then clear the array, to avoid race conditions for the price of a little extra memory usage?

Copy link
Collaborator

Choose a reason for hiding this comment

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

will look into this

this.isRenderable === true &&
this.parentAutosizer !== null
) {
this.parentAutosizer.patch(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

could do patch(this._id)

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed

}
}

detach(node: CoreNode) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this could also be by id instead of CoreNode to reduce GC pressure a bit

Copy link
Collaborator

@jfboeve jfboeve Jan 15, 2026

Choose a reason for hiding this comment

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

agreed, on later review, this avoids extra map call.

@wouterlucas wouterlucas added this pull request to the merge queue Jan 19, 2026
Merged via the queue into main with commit de67998 Jan 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants