Skip to content
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

Center of flex element is not aligned with parent object center. #71

Open
oveddan opened this issue Oct 22, 2021 · 1 comment
Open

Center of flex element is not aligned with parent object center. #71

oveddan opened this issue Oct 22, 2021 · 1 comment

Comments

@oveddan
Copy link

oveddan commented Oct 22, 2021

I want to be able to align items outside of a Flex element with the Flex element. However this seems challenging to do because the flex element itself has a center that is not aligned with the parent center.

Take this code, for example, viewable in this sandbox:

    <group position-z={-1}>
      <Flex flexDirection="row" alignItems="baseline">
        <Box>
          <mesh scale-y={1.5} >
            <meshBasicMaterial color="green" />
            <boxBufferGeometry />
          </mesh>
        </Box>
        <Box>
          <mesh>
            <meshBasicMaterial color="red" />
            <boxBufferGeometry />
          </mesh>
        </Box>
      </Flex>
      <mesh scale-y={1.5} >
        <meshBasicMaterial color="yellow"/>
        <planeBufferGeometry args={[2,2]} />
      </mesh>
    </group>

This results in:
Screen Shot 2021-10-22 at 11 16 52 AM

I would expect the rendered plane to be center aligned both vertically and horizontally with the Flex element, but the horizontal alignment is off. Is there a recommended way to achieve this?

@oveddan oveddan changed the title Center of entire flex element is not on parent object center. Center of flex element is aligned with parent object center. Oct 22, 2021
@oveddan oveddan changed the title Center of flex element is aligned with parent object center. Center of flex element is not aligned with parent object center. Oct 22, 2021
@saitonakamura
Copy link
Sponsor Collaborator

@oveddan can you illustrate the result you're trying to achieve, cause i'm not entirely sure I understood you correctly? Although, I see at least one problem, you need to give Box a centerAnchor if children are the meshes/groups/or any threejs stuff (cause they use position as center, not top left), see the docs

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

No branches or pull requests

2 participants