-
Notifications
You must be signed in to change notification settings - Fork 32
Autosize node based on children #681
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
Conversation
…t to fall in line with css and renderer 2
src/core/Autosizer.ts
Outdated
| w: number, | ||
| h: number, | ||
| ) => { | ||
| if (carryOver === true) { |
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.
what does carryOver do/mean?
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.
forget about this, I removed it and changed a bit of logic to avoid unnessecary calcs.
wouterlucas
left a comment
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.
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.
src/core/Autosizer.ts
Outdated
| } | ||
| } | ||
|
|
||
| patch(node: CoreNode) { |
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.
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 😄
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.
agreed
src/core/Autosizer.ts
Outdated
| if (corner.y > maxY) maxY = corner.y; | ||
| } | ||
| } | ||
| this.flaggedChildren.length = 0; |
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 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?
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.
will look into this
src/core/CoreNode.ts
Outdated
| this.isRenderable === true && | ||
| this.parentAutosizer !== null | ||
| ) { | ||
| this.parentAutosizer.patch(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.
could do patch(this._id)
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.
agreed
| } | ||
| } | ||
|
|
||
| detach(node: CoreNode) { |
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 could also be by id instead of CoreNode to reduce GC pressure a bit
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.
agreed, on later review, this avoids extra map call.
Add autosize to a node to dynamically update its size based on children's matrix3d.
autosizepropertynotes:
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.