Skip to content

Commit 6901f10

Browse files
committed
Add vertical, horizontal and horizontalDirected funcs to absolute positioning
1 parent 21921a7 commit 6901f10

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

Sources/FlexLayout.swift

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,73 @@ public final class Flex {
648648
return self
649649
}
650650

651+
/**
652+
Set the left and right edges distance from the container edges in pixels.
653+
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
654+
*/
655+
@discardableResult
656+
public func horizontal(_ value: CGFloat) -> Flex {
657+
yoga.left = YGValue(value)
658+
yoga.right = YGValue(value)
659+
return self
660+
}
661+
662+
/**
663+
Set the left and right edges distance from the container edges in percentage of its container width.
664+
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
665+
*/
666+
@discardableResult
667+
public func horizontal(_ percent: FPercent) -> Flex {
668+
yoga.left = YGValue(value: Float(percent.value), unit: .percent)
669+
yoga.right = YGValue(value: Float(percent.value), unit: .percent)
670+
return self
671+
}
672+
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+
696+
/**
697+
Set the top and bottom edges distance from the container edges in pixels.
698+
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
699+
*/
700+
@discardableResult
701+
public func vertical(_ value: CGFloat) -> Flex {
702+
yoga.top = YGValue(value)
703+
yoga.bottom = YGValue(value)
704+
return self
705+
}
706+
707+
/**
708+
Set the top and bottom edges distance from the container edges in percentage of its container height.
709+
This method is valid only when the item position is absolute (`view.flex.position(.absolute)`)
710+
*/
711+
@discardableResult
712+
public func vertical(_ percent: FPercent) -> Flex {
713+
yoga.top = YGValue(value: Float(percent.value), unit: .percent)
714+
yoga.bottom = YGValue(value: Float(percent.value), unit: .percent)
715+
return self
716+
}
717+
651718
//
652719
// MARK: Margins
653720
//

0 commit comments

Comments
 (0)