Skip to content

Commit

Permalink
Merge pull request #4 from c941010623/main
Browse files Browse the repository at this point in the history
Fixed Multi-touch interference
  • Loading branch information
michael94ellis authored Jan 11, 2022
2 parents 551744c + f934124 commit 5bd303c
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Sources/SwiftUIJoystick/JoystickRecognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ public struct JoystickGestureRecognizer: ViewModifier {
self.emitPosition(for: .zero)
}
})
.exclusively(
before:
LongPressGesture(minimumDuration: 0.0, maximumDistance: 0.0)
.onEnded({ _ in
if !locksInPlace {
self.thumbPosition = self.midPoint
self.emitPosition(for: .zero)
}
})
)
)
}

Expand All @@ -109,7 +119,7 @@ public struct JoystickGestureRecognizer: ViewModifier {
/// - parameter content: The view for which to apply the Joystick listener/DragGesture
public func circleBody(_ content: Content) -> some View {
content
.contentShape(Rectangle())
.contentShape(Circle())
.gesture(
DragGesture(minimumDistance: 0, coordinateSpace: .local)
.onChanged() { value in
Expand All @@ -133,6 +143,16 @@ public struct JoystickGestureRecognizer: ViewModifier {
self.emitPosition(for: .zero)
}
})
.exclusively(
before:
LongPressGesture(minimumDuration: 0.0, maximumDistance: 0.0)
.onEnded({ _ in
if !locksInPlace {
self.thumbPosition = self.midPoint
self.emitPosition(for: .zero)
}
})
)
)
}
}
Expand Down

0 comments on commit 5bd303c

Please sign in to comment.