Skip to content

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

Description

@oveddan

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions