Skip to content

Commit 5bd303c

Browse files
Merge pull request #4 from c941010623/main
Fixed Multi-touch interference
2 parents 551744c + f934124 commit 5bd303c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Sources/SwiftUIJoystick/JoystickRecognizer.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ public struct JoystickGestureRecognizer: ViewModifier {
101101
self.emitPosition(for: .zero)
102102
}
103103
})
104+
.exclusively(
105+
before:
106+
LongPressGesture(minimumDuration: 0.0, maximumDistance: 0.0)
107+
.onEnded({ _ in
108+
if !locksInPlace {
109+
self.thumbPosition = self.midPoint
110+
self.emitPosition(for: .zero)
111+
}
112+
})
113+
)
104114
)
105115
}
106116

@@ -109,7 +119,7 @@ public struct JoystickGestureRecognizer: ViewModifier {
109119
/// - parameter content: The view for which to apply the Joystick listener/DragGesture
110120
public func circleBody(_ content: Content) -> some View {
111121
content
112-
.contentShape(Rectangle())
122+
.contentShape(Circle())
113123
.gesture(
114124
DragGesture(minimumDistance: 0, coordinateSpace: .local)
115125
.onChanged() { value in
@@ -133,6 +143,16 @@ public struct JoystickGestureRecognizer: ViewModifier {
133143
self.emitPosition(for: .zero)
134144
}
135145
})
146+
.exclusively(
147+
before:
148+
LongPressGesture(minimumDuration: 0.0, maximumDistance: 0.0)
149+
.onEnded({ _ in
150+
if !locksInPlace {
151+
self.thumbPosition = self.midPoint
152+
self.emitPosition(for: .zero)
153+
}
154+
})
155+
)
136156
)
137157
}
138158
}

0 commit comments

Comments
 (0)