diff Sources/StockCharts/LineChart/Helpers/LineView.swift @ 60:e16e6bdaa31d

Add dragGesture argument
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Fri, 07 May 2021 12:20:48 +0200
parents 127af64e264e
children e0c0306fb079
line wrap: on
line diff
--- a/Sources/StockCharts/LineChart/Helpers/LineView.swift	Mon May 03 17:51:39 2021 +0200
+++ b/Sources/StockCharts/LineChart/Helpers/LineView.swift	Fri May 07 12:20:48 2021 +0200
@@ -11,6 +11,7 @@
     public var data: [Double]
     public var dates: [String]?
     public var hours: [String]?
+    public var dragGesture: Bool?
     
     @Binding var showingIndicators: Bool
     @Binding var indexPosition: Int
@@ -32,7 +33,7 @@
         .rotationEffect(.degrees(180), anchor: .center)
         .rotation3DEffect(.degrees(180), axis: (x: 0.0, y: 1.0, z: 0.0))
         .contentShape(Rectangle())  // Control tappable area
-        .gesture(
+        .gesture(dragGesture ?? true ?
             LongPressGesture(minimumDuration: 0.2)
                 .sequenced(before: DragGesture(minimumDistance: 0, coordinateSpace: .local))
                 .onChanged({ value in  // Get value of the gesture
@@ -49,6 +50,7 @@
                 .onEnded({ value in
                     self.showingIndicators = false
                 })
+            : nil  // On dragGesture = false
         )
     }