Skip to content

Commit 562aadb

Browse files
committed
Add direction property in flex class
- It's used when a layout needs to be changed according to the direction of a flex item. - For example, when developing an UI component, you can use it to change the layout according to the direction of the super container view.
1 parent dc4235f commit 562aadb

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,16 @@ Item natural size, considering only properties of the view itself. Independent o
755755

756756
<br>
757757

758+
### direction
759+
- Applies to: `flex items`
760+
761+
**Property:**
762+
763+
* **`direction`**
764+
This `direction` property is get the direction flex items are placed in the flex container.
765+
766+
<br>
767+
758768
<a name="absolute_positioning"></a>
759769
## 4. Absolute positioning
760770
- Applies to: `flex items`

Sources/Swift/FlexLayout.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ public final class Flex {
4343
public var intrinsicSize: CGSize {
4444
return yoga.intrinsicSize
4545
}
46+
47+
/**
48+
This`direction` property is get the direction flex items are placed in the flex container.
49+
*/
50+
public var direction: Direction? {
51+
switch yoga.flexDirection {
52+
case .column: return Flex.Direction.column
53+
case .columnReverse: return Flex.Direction.columnReverse
54+
case .row: return Flex.Direction.row
55+
case .rowReverse: return Flex.Direction.rowReverse
56+
@unknown default: return nil
57+
}
58+
}
4659

4760
init(view: UIView) {
4861
self.view = view

0 commit comments

Comments
 (0)