You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that root_node has padding of 5px, child_1_node should be as small vertically as necessary, child_2_node should take the remaining space. I'm computing the layout for a size of 1000 x 800.
The above code has the negative margins on child_1_style commented out, and the output is as expected:
child_1 starts at y: 5 due to the parent's top padding, and has a height of 10. child_2 starts at y: 15 and has height of 780, leaving 5 for the parent's bottom padding.
This roughly corresponds to this layout (ignore overall size, it's a rough HTML equivalent):
However, if I uncomment the negative margins on child_1, I would expect the following layout:
child_1 is correctly starting at y: 0, bleeding into the parent padding as expected, with a height of 10. child_2 correctly starts at y: 10, but the height is 790, leaving no space for the parent's padding at the bottom. I would expect it to have a height of 785.
Note child_2 does not have any negative margins, and should not be bleeding into the parent's padding. It seems like it's correctly been given extra space due to child_1 moving up, but has used twice as much extra space as it should have.
If you add an extra child which does bleed into the bottom margin:
let child_3_style = Style{flex_basis:auto(),flex_grow:0.,flex_shrink:0.,margin:Rect{top:length(0.),left:length(negative_padding),right:length(negative_padding),bottom:length(negative_padding),},
..Default::default()};let child_3_node = tree
.new_leaf_with_context(child_3_style,NodeContext::Spacer).unwrap();
taffy
version0.5.2
Platform
Rust
What you did
I'm trying to use negative margins to bleed child elements into the parent padding, however the resulting layout appears to be incorrect.
The simplest example I've come up with is the following code:
Note that
root_node
has padding of5px
,child_1_node
should be as small vertically as necessary,child_2_node
should take the remaining space. I'm computing the layout for a size of 1000 x 800.The above code has the negative margins on
child_1_style
commented out, and the output is as expected:child_1
starts aty: 5
due to the parent's top padding, and has a height of 10.child_2
starts aty: 15
and has height of780
, leaving5
for the parent's bottom padding.This roughly corresponds to this layout (ignore overall size, it's a rough HTML equivalent):
However, if I uncomment the negative margins on
child_1
, I would expect the following layout:But instead I get this:
child_1
is correctly starting aty: 0
, bleeding into the parent padding as expected, with a height of 10.child_2
correctly starts aty: 10
, but the height is790
, leaving no space for the parent's padding at the bottom. I would expect it to have a height of 785.Note
child_2
does not have any negative margins, and should not be bleeding into the parent's padding. It seems like it's correctly been given extra space due tochild_1
moving up, but has used twice as much extra space as it should have.If you add an extra child which does bleed into the bottom margin:
You get the following:
child_3
is rendered completely outside the box (y: 800
), when it should look like this:What went wrong
Negative margins seem to result in the layout being computed incorrectly.
Related to #475
The text was updated successfully, but these errors were encountered: