Skip to content

Commit

Permalink
Do not make any modification to offset with respect to layout directi…
Browse files Browse the repository at this point in the history
…on, which fixes roberthein#95
  • Loading branch information
therohansanap committed Apr 24, 2021
1 parent d7bd595 commit 109eda0
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions TinyConstraints/Classes/TinyConstraints+superview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,17 @@
@discardableResult
func leadingToSuperview( _ anchor: NSLayoutXAxisAnchor? = nil, offset: CGFloat = 0, relation: ConstraintRelation = .equal, priority: LayoutPriority = .required, isActive: Bool = true, usingSafeArea: Bool = false) -> Constraint {
let constrainable = safeConstrainable(for: superview, usingSafeArea: usingSafeArea)

if effectiveUserInterfaceLayoutDirection == .rightToLeft {
return leading(to: constrainable, anchor, offset: -offset, relation: relation, priority: priority, isActive: isActive)
} else {
return leading(to: constrainable, anchor, offset: offset, relation: relation, priority: priority, isActive: isActive)
}

return leading(to: constrainable, anchor, offset: offset, relation: relation, priority: priority, isActive: isActive)
}

@available(tvOS 10.0, *)
@available(iOS 10.0, *)
@discardableResult
func trailingToSuperview( _ anchor: NSLayoutXAxisAnchor? = nil, offset: CGFloat = 0, relation: ConstraintRelation = .equal, priority: LayoutPriority = .required, isActive: Bool = true, usingSafeArea: Bool = false) -> Constraint {
let constrainable = safeConstrainable(for: superview, usingSafeArea: usingSafeArea)

if effectiveUserInterfaceLayoutDirection == .rightToLeft {
return trailing(to: constrainable, anchor, offset: offset, relation: relation, priority: priority, isActive: isActive)
} else {
return trailing(to: constrainable, anchor, offset: -offset, relation: relation, priority: priority, isActive: isActive)
}

return trailing(to: constrainable, anchor, offset: offset, relation: relation, priority: priority, isActive: isActive)
}

@available(tvOS 10.0, *)
Expand Down

0 comments on commit 109eda0

Please sign in to comment.