Skip to content

Commit 77b6899

Browse files
committed
Fix an issue with BarChartView preveting scrolling
1 parent 2bc660f commit 77b6899

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

Modules/Sources/JetpackStats/Charts/BarChartView.swift

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ struct BarChartView: View {
77

88
@State private var selectedDataPoints: SelectedDataPoints?
99
@State private var isDragging = false
10-
@State private var isLongPressing = false
11-
@State private var longPressLocation: CGPoint?
1210
@State private var tappedDataPoint: DataPoint?
1311

1412
@Environment(\.context) var context
@@ -246,43 +244,15 @@ struct BarChartView: View {
246244
.onTapGesture { location in
247245
handleTapGesture(at: location, proxy: proxy, geometry: geometry)
248246
}
249-
.onLongPressGesture(minimumDuration: 0.3) {
250-
// Long press completed - keep showing annotation
251-
} onPressingChanged: { isPressing in
252-
if isPressing {
253-
// Long press started - show annotation at current location
254-
if let location = longPressLocation {
255-
isLongPressing = true
256-
selectedDataPoints = getSelectedDataPoints(at: location, proxy: proxy, geometry: geometry)
257-
}
258-
} else {
259-
// Long press ended - clear annotation
260-
isLongPressing = false
261-
longPressLocation = nil
262-
if !isDragging {
263-
selectedDataPoints = nil
264-
}
265-
tappedDataPoint = nil
266-
}
267-
}
268247
.simultaneousGesture(
269-
DragGesture(minimumDistance: 0)
248+
DragGesture(minimumDistance: 16)
270249
.onChanged { value in
271-
// Store location for long press
272-
longPressLocation = value.location
273-
274-
// Handle drag if moved enough
275-
if value.translation.width.magnitude > 8 || value.translation.height.magnitude > 8 {
276-
isDragging = true
277-
selectedDataPoints = getSelectedDataPoints(at: value.location, proxy: proxy, geometry: geometry)
278-
}
250+
isDragging = true
251+
selectedDataPoints = getSelectedDataPoints(at: value.location, proxy: proxy, geometry: geometry)
279252
}
280253
.onEnded { _ in
281254
isDragging = false
282-
longPressLocation = nil
283-
if !isLongPressing {
284-
selectedDataPoints = nil
285-
}
255+
selectedDataPoints = nil
286256
tappedDataPoint = nil
287257
}
288258
)
@@ -291,7 +261,7 @@ struct BarChartView: View {
291261

292262
private func handleTapGesture(at location: CGPoint, proxy: ChartProxy, geometry: GeometryProxy) {
293263
// Only handle tap if not dragging or long pressing
294-
guard !isDragging && !isLongPressing else { return }
264+
guard !isDragging else { return }
295265

296266
guard let onDateSelected,
297267
data.granularity != .hour,

0 commit comments

Comments
 (0)