Skip to content

Commit 1f0bf33

Browse files
committed
Add readme. Rename vertical -> vertical(ly)
1 parent 6901f10 commit 1f0bf33

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ The position property tells Flexbox how you want your item to be positioned with
780780
view.flex.position(.absolute).top(10).left(10).size(50)
781781
```
782782

783-
### top(), bottom(), left(), right(), start(), end()
783+
### top(), bottom(), left(), right(), start(), end(), vertical(), vertically(), horizontally()
784784
A flex item which is `position` is set to `.absolute` is positioned absolutely in regards to its parent. This is done through the following methods:
785785

786786
**Methods:**
@@ -797,6 +797,11 @@ Controls the distance a child’s right edge is from the parent’s right edge.
797797
Controls the distance a child’s start edge is from the parent’s start edge. In left-to-right direction (LTR), it corresponds to the `left()` property and in RTL to `right()` property.
798798
* **`end(: CGFloat)`** / **`end(: FPercent)`**:
799799
Controls the distance a child’s end edge is from the parent’s end edge. In left-to-right direction (LTR), it corresponds to the `right()` property and in RTL to `left()` property.
800+
* **`vertically(: CGFloat)`** / **`vertically(: FPercent)`**:
801+
Controls the distance child’s top and bottom edges from the parent’s edges. Equal to `top().bottom()`.
802+
* **`horizontally(: CGFloat)`** / **`horizontally(: FPercent)`**:
803+
Controls the distance child’s left and right edges from the parent’s edges. Equal to `left().right()`.
804+
800805

801806
Using these properties you can control the size and position of an absolute item within its parent. Because absolutely positioned children don’t affect their sibling's layout. Absolute position can be used to create overlays and stack children in the Z axis.
802807

Sources/FlexLayout.swift

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ public final class Flex {
653653
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
654654
*/
655655
@discardableResult
656-
public func horizontal(_ value: CGFloat) -> Flex {
656+
public func horizontally(_ value: CGFloat) -> Flex {
657657
yoga.left = YGValue(value)
658658
yoga.right = YGValue(value)
659659
return self
@@ -664,41 +664,18 @@ public final class Flex {
664664
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
665665
*/
666666
@discardableResult
667-
public func horizontal(_ percent: FPercent) -> Flex {
667+
public func horizontally(_ percent: FPercent) -> Flex {
668668
yoga.left = YGValue(value: Float(percent.value), unit: .percent)
669669
yoga.right = YGValue(value: Float(percent.value), unit: .percent)
670670
return self
671671
}
672672

673-
/**
674-
Set the start and end edges (LTR=right, RTL=left) distance from the container edges in pixels.
675-
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
676-
*/
677-
@discardableResult
678-
public func horizontalDirected(_ value: CGFloat) -> Flex {
679-
yoga.start = YGValue(value)
680-
yoga.end = YGValue(value)
681-
return self
682-
}
683-
684-
/**
685-
Set the start and end edges (LTR=right, RTL=left) distance from the container edges in
686-
percentage of its container width.
687-
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
688-
*/
689-
@discardableResult
690-
public func horizontalDirected(_ percent: FPercent) -> Flex {
691-
yoga.start = YGValue(value: Float(percent.value), unit: .percent)
692-
yoga.end = YGValue(value: Float(percent.value), unit: .percent)
693-
return self
694-
}
695-
696673
/**
697674
Set the top and bottom edges distance from the container edges in pixels.
698675
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
699676
*/
700677
@discardableResult
701-
public func vertical(_ value: CGFloat) -> Flex {
678+
public func vertically(_ value: CGFloat) -> Flex {
702679
yoga.top = YGValue(value)
703680
yoga.bottom = YGValue(value)
704681
return self
@@ -709,7 +686,7 @@ public final class Flex {
709686
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
710687
*/
711688
@discardableResult
712-
public func vertical(_ percent: FPercent) -> Flex {
689+
public func vertically(_ percent: FPercent) -> Flex {
713690
yoga.top = YGValue(value: Float(percent.value), unit: .percent)
714691
yoga.bottom = YGValue(value: Float(percent.value), unit: .percent)
715692
return self

0 commit comments

Comments
 (0)