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
use taffy::prelude::*;// First create an instance of TaffyTreeletmut tree:TaffyTree<()> = TaffyTree::new();let node1 = tree
.new_leaf(Style{size:Size{width:length(100.0),height:length(50.0)},margin:Rect::<LengthPercentageAuto>{bottom:LengthPercentageAuto::Length(0.0),top:LengthPercentageAuto::Length(10.0),left:LengthPercentageAuto::Length(0.0),right:LengthPercentageAuto::Length(0.0),},
..Default::default()}).unwrap();let node2 = tree
.new_leaf(Style{size:Size{width:length(100.0),height:length(50.0)},margin:Rect::<LengthPercentageAuto>{bottom:LengthPercentageAuto::Length(0.0),top:LengthPercentageAuto::Length(10.0),left:LengthPercentageAuto::Length(0.0),right:LengthPercentageAuto::Length(0.0),},
..Default::default()}).unwrap();let root_node = tree
.new_with_children(Style{display:Display::Block,position:Position::Relative,size:Size{width:length(100.0),height:length(100.0)},
..Default::default()},&[node1, node2],).unwrap();
tree.compute_layout(root_node,Size::MAX_CONTENT).unwrap();assert_eq!(tree.layout(node1).unwrap().location.y, 0.0);assert_eq!(tree.layout(node2).unwrap().location.y, 60.0);
What went wrong
When Display::Block is set for a root node, margin collapsing doesn't work for its direct children.
@thecodrr I may be wrong, but looking at this example again, I don't think that there should be any margin collapsing happening here. I believe your example is equivalent to the following HTML:
taffy
version563d5dc
Platform
Rust
What you did
What went wrong
When
Display::Block
is set for a root node, margin collapsing doesn't work for its direct children.Additional information
This is probably occuring due to this line:
taffy/src/compute/mod.rs
Line 48 in 563d5dc
The text was updated successfully, but these errors were encountered: