-
Notifications
You must be signed in to change notification settings - Fork 42
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
Nested flex #13
Nested flex #13
Conversation
@@ -125,14 +184,14 @@ export function Box({ | |||
// Make child known to the parents yoga instance *before* it calculates layout | |||
useLayoutEffect(() => { | |||
parent.insertChild(node, parent.getChildCount()) | |||
registerBox(group.current, node) | |||
registerBox(group.current, node, flexProps, centerAnchor) |
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.
I think that passing flexProps can be a bit slow BTW
@@ -15,6 +15,7 @@ import { useReflow } from './Flex' | |||
export function Box({ | |||
// Non-flex props | |||
children, | |||
centerAnchor, |
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.
centerAnchor
is a new prop that you have to set if your children has position centered.
While a inside another is relative to the upper left corner, all THREE standard shapes are referred to the center.
src/Flex.tsx
Outdated
boundingBox.setFromObject(group).getSize(vec) | ||
node.setWidth(vec[state.mainAxis]) | ||
node.setHeight(vec[state.crossAxis]) | ||
node.setWidth(flexProps.width || vec[state.mainAxis]) |
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 way we can force width
and height
directly, ignoring the content bounding box.
This could be optimized preventing the bounding box calculation if props are present.
6e0ab8a
to
4735f2e
Compare
Closes #10
and also regards #7 if some optimizations are considered
This fixes some things to make nested Flexbox work again properly.
README is still a WIP.
This changes nested flex semantic:
OLD
NEW