From 96ff2a8d63f6fc47df1df98daf4416c0f7236216 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Mon, 16 Dec 2024 13:48:12 +1300 Subject: [PATCH] Document that Taffy percentages are represented by the range [0, 1] not [0, 100] Signed-off-by: Nico Burns --- src/style/dimension.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/style/dimension.rs b/src/style/dimension.rs index 35ee8d27a..3b2cfb3da 100644 --- a/src/style/dimension.rs +++ b/src/style/dimension.rs @@ -13,7 +13,9 @@ pub enum LengthPercentage { /// An absolute length in some abstract units. Users of Taffy may define what they correspond /// to in their application (pixels, logical pixels, mm, etc) as they see fit. Length(f32), - /// The dimension is stored in percentage relative to the parent item. + /// A percentage length relative to the size of the containing block. + /// + /// **NOTE: percentages are represented as a f32 value in the range [0.0, 1.0] NOT the range [0.0, 100.0]** Percent(f32), } impl TaffyZero for LengthPercentage { @@ -39,7 +41,9 @@ pub enum LengthPercentageAuto { /// An absolute length in some abstract units. Users of Taffy may define what they correspond /// to in their application (pixels, logical pixels, mm, etc) as they see fit. Length(f32), - /// The dimension is stored in percentage relative to the parent item. + /// A percentage length relative to the size of the containing block. + /// + /// **NOTE: percentages are represented as a f32 value in the range [0.0, 1.0] NOT the range [0.0, 100.0]** Percent(f32), /// The dimension should be automatically computed Auto, @@ -100,7 +104,9 @@ pub enum Dimension { /// An absolute length in some abstract units. Users of Taffy may define what they correspond /// to in their application (pixels, logical pixels, mm, etc) as they see fit. Length(f32), - /// The dimension is stored in percentage relative to the parent item. + /// A percentage length relative to the size of the containing block. + /// + /// **NOTE: percentages are represented as a f32 value in the range [0.0, 1.0] NOT the range [0.0, 100.0]** Percent(f32), /// The dimension should be automatically computed Auto,