Skip to content

Commit

Permalink
Update FloatingItemGestureRecognizer.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
noppefoxwolf committed Nov 23, 2021
1 parent 6f37302 commit 44cd662
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion Sources/DebugMenu/Extensions/FloatingItemGestureRecognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ public class FloatingItemGestureRecognizer: UIPanGestureRecognizer {
private var gestureGap: CGPoint?
private let margin: CGFloat = 16
public enum Edge {
case top
// case center
case bottom

case topLeading
case topTrailing

case leading
case trailing

case bottomLeading
case bottomTrailing
}
Expand Down Expand Up @@ -151,15 +159,35 @@ public class FloatingItemGestureRecognizer: UIPanGestureRecognizer {
let yCenter = targetView.bounds.height / 2
let safeAreaInsets = groundView.safeAreaInsets


let top = CGPoint(
x: viewSize.width / 2,
y: self.margin + yCenter + safeAreaInsets.top
)
let bottom = CGPoint(
x: viewSize.width / 2,
y: viewSize.height - objectSize.height - self.margin + yCenter - safeAreaInsets.bottom
)

let topLeading = CGPoint(
x: self.margin + xCenter + safeAreaInsets.left,
y: self.margin + yCenter + safeAreaInsets.top
)

let topTrailing = CGPoint(
x: viewSize.width - objectSize.width - self.margin + xCenter - safeAreaInsets.right,
y: self.margin + yCenter + safeAreaInsets.top
)

let leading = CGPoint(
x: self.margin + xCenter + safeAreaInsets.left,
y: viewSize.height / 2
)

let trailing = CGPoint(
x: viewSize.width - objectSize.width - self.margin + xCenter - safeAreaInsets.right,
y: viewSize.height / 2
)

let bottomLeading = CGPoint(
x: self.margin + xCenter + safeAreaInsets.left,
y: viewSize.height - objectSize.height - self.margin + yCenter - safeAreaInsets.bottom
Expand All @@ -170,8 +198,15 @@ public class FloatingItemGestureRecognizer: UIPanGestureRecognizer {
y: viewSize.height - objectSize.height - self.margin + yCenter - safeAreaInsets.bottom
)
return [
.top: top,
.bottom: bottom,

.topLeading: topLeading,
.topTrailing: topTrailing,

.leading: leading,
.trailing: trailing,

.bottomLeading: bottomLeading,
.bottomTrailing: bottomTrailing,
]
Expand Down

0 comments on commit 44cd662

Please sign in to comment.