Skip to content

Commit 7513d32

Browse files
authored
Merge pull request #128 from AndreasMattsson/feature/allow-basis-percent
flexBasis supports percentage values
2 parents 3a70936 + efda412 commit 7513d32

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Sources/FlexLayout.swift

+15
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,21 @@ public final class Flex {
330330
return self
331331
}
332332

333+
/**
334+
This property takes the same values as the width and height properties, and specifies the initial size of the
335+
flex item, before free space is distributed according to the grow and shrink factors.
336+
337+
Specifying `nil` set the basis as `auto`, which means the length is equal to the length of the item. If the
338+
item has no length specified, the length will be according to its content.
339+
340+
- Parameter value: Default value is 0
341+
*/
342+
@discardableResult
343+
public func basis(_ percent: FPercent) -> Flex {
344+
yoga.flexBasis = YGValue(value: Float(percent.value), unit: .percent)
345+
return self
346+
}
347+
333348
//
334349
// MARK: Width / height / height
335350
//

0 commit comments

Comments
 (0)