Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that Taffy percentages are represented by the range [0, 1] not [0, 100] #764

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/style/dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading