Skip to content

Commit 9109f6b

Browse files
committed
Trying again to fix macOS issues
1 parent 3769774 commit 9109f6b

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

Sources/Sliders/RadialSlider.swift

+5-15
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ public struct RSlider: View {
215215

216216
private func calculateDirection(_ pt1: CGPoint, _ pt2: CGPoint) -> Double {
217217
let a = pt2.x - pt1.x
218+
#if os(macOS)
219+
let b = -pt2.y - pt1.y
220+
#else
218221
let b = pt2.y - pt1.y
219-
222+
#endif
220223
return Double(atanP(x: a, y: b)/(2 * .pi))
221224
}
222225
private var configuration: RSliderConfiguration {
@@ -233,19 +236,7 @@ public struct RSlider: View {
233236
private func makeThumb(_ proxy: GeometryProxy) -> some View {
234237
let radius = min(proxy.size.height, proxy.size.width)/2
235238
let middle = CGPoint(x: proxy.frame(in: .global).midX, y: proxy.frame(in: .global).midY)
236-
#if os(macOS)
237-
let gesture = DragGesture(minimumDistance: 0)
238-
.onChanged { (value) in
239-
let direction = self.calculateDirection(middle, value.location)
240-
self.value = direction*(self.range.upperBound-self.range.lowerBound) + self.range.lowerBound
241-
self.isActive = true
242-
}
243-
.onEnded { (value) in
244-
let direction = self.calculateDirection(middle, value.location)
245-
self.value = direction*(self.range.upperBound-self.range.lowerBound) + self.range.lowerBound
246-
self.isActive = false
247-
}
248-
#else
239+
249240
let gesture = DragGesture(minimumDistance: 0, coordinateSpace: .global)
250241
.onChanged { (value) in
251242
let direction = self.calculateDirection(middle, value.location)
@@ -257,7 +248,6 @@ public struct RSlider: View {
257248
self.value = direction*(self.range.upperBound-self.range.lowerBound) + self.range.lowerBound
258249
self.isActive = false
259250
}
260-
#endif
261251
let pct = (value-range.lowerBound)/(range.upperBound-range.lowerBound)
262252
let pX = radius*CGFloat(cos(pct*2 * .pi ))
263253
let pY = radius*CGFloat(sin(pct*2 * .pi ))

0 commit comments

Comments
 (0)