Skip to content

Commit

Permalink
New translationOffset property
Browse files Browse the repository at this point in the history
  • Loading branch information
kennic committed Nov 22, 2020
1 parent 9e55ea1 commit cf34010
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FrameLayoutKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'FrameLayoutKit'
s.version = '5.1.4'
s.version = '5.2.0'
s.summary = 'FrameLayoutKit is a super fast and easy to use layout kit'
s.description = <<-DESC
An auto layout kit helps you to layout your UI easier, faster and more effective
Expand Down
19 changes: 18 additions & 1 deletion FrameLayoutKit/Classes/FrameLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ open class FrameLayout: UIView {
public var ignoreHiddenView = true
/// Padding edge insets
public var edgeInsets: UIEdgeInsets = .zero
/// Add translation position to view
public var translationOffset: CGPoint = .zero
public var translationX: CGFloat {
get { translationOffset.x }
set {
translationOffset.x = newValue
setNeedsLayout()
}
}
public var translationY: CGFloat {
get { translationOffset.y }
set {
translationOffset.y = newValue
setNeedsLayout()
}
}
/// Minimum size of frameLayout
public var minSize: CGSize = .zero
public var minWidth: CGFloat {
Expand Down Expand Up @@ -468,6 +484,7 @@ open class FrameLayout: UIView {

targetFrame.size.limitedTo(minSize: minContentSize, maxSize: maxContentSize)
targetFrame = targetFrame.integral
targetFrame = targetFrame.offsetBy(dx: translationOffset.x, dy: translationOffset.y)

if targetView.superview == self {
targetView.frame = targetFrame
Expand All @@ -484,7 +501,7 @@ open class FrameLayout: UIView {
superView = superView!.superview
}

targetView.frame = targetFrame
targetView.frame = targetFrame.offsetBy(dx: translationOffset.x, dy: translationOffset.y)
}
else {
targetView.frame = convert(targetFrame, to: targetView.superview)
Expand Down

0 comments on commit cf34010

Please sign in to comment.