这是indexloc提供的服务,不要输入任何密码
Skip to content

1 pixel gap between sibling nodes #834

@jfto23

Description

@jfto23

taffy version

Tested on both v0.5.0 and v0.8.0.

Platform

Mac m2

What you did

pub fn main() -> Result<(), taffy::TaffyError> {

    use taffy::prelude::*;

    let mut taffy: TaffyTree<()> = TaffyTree::new();

    let flex = Style {
        justify_content: Some(AlignContent::Center),
        size: Size { width: percent(1.0), height: percent(1.0) },
        ..default()
    };

    let sub_style = Style {
        display: Display::Grid,
        size: Size { width: percent(0.5), height: length(600.0) },
        grid_template_columns: vec![fr(1.0), fr(1.0) ],
        grid_template_rows: vec![fr(1.0)] ,
        ..default()
    };

    let left = taffy.new_leaf(Style { grid_row: line(1), grid_column: line(1), ..default() })?;
    let right = taffy.new_leaf(Style { grid_row: line(1), grid_column: line(2), ..default() })?;

    let sub = taffy.new_with_children(sub_style, &[left, right])?;
    let root = taffy.new_with_children(flex, &[sub])?;

    taffy.compute_layout(root, Size { width: length(350.0), height: length(600.0) })?;
    taffy.print_tree(root);

    Ok(())
}

What went wrong

I get a gap between the left and right node:

TREE
└──  FLEX ROW [x: 0    y: 0    w: 350  h: 600  content_w: 263  content_h: 600  border: l:0 r:0 t:0
 b:0, padding: l:0 r:0 t:0 b:0] (NodeId(4294967300))
    └──  GRID [x: 88   y: 0    w: 175  h: 600  content_w: 175  content_h: 600  border: l:0 r:0 t:0
 b:0, padding: l:0 r:0 t:0 b:0] (NodeId(4294967299))
        ├──  LEAF [x: 0    y: 0    w: 87   h: 600  content_w: 0    content_h: 0    border: l:0 r:0
 t:0 b:0, padding: l:0 r:0 t:0 b:0] (NodeId(4294967297))
        └──  LEAF [x: 88   y: 0    w: 88   h: 600  content_w: 0    content_h: 0    border: l:0 r:0
 t:0 b:0, padding: l:0 r:0 t:0 b:0] (NodeId(4294967298))

Additional information

I think this might be related to this bevy issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions