title: Is There Any Important Difference Between These Two SwiftUI Drag Gesture Implementations?
body: <h1>Drag Gesture Implementation</h1>
  
  <p>While trying to make a simple drag gesture without the long press I found that two different ways seem to produce the same result. I am unsure if one method is preferable to another or if both are equally valid.</p>
  
  <h2>Example 1</h2>
  
  <p>Here I used @State CGSize values to represent both the viewState and the dragState</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct Example1: View {
      @State var viewState: CGSize = .zero
      @State var dragState: CGSize = .zero
  
      var body: some View {
          let dragGesture = DragGesture()
              .onChanged { (value) in
                  self.dragState = value.translation
          }.onEnded { (value) in
              self.viewState.width += value.translation.width
              self.viewState.height += value.translation.height
              self.dragState = .zero
          }
          return Circle().foregroundColor(.blue).frame(width: 20, height: 20)
              .offset(x: dragState.width + viewState.width,
                      y: dragState.height + viewState.height)
              .gesture(dragGesture)
  
      }
  }
  </code></pre>
  
  <h2>Example 2</h2>
  
  <p>This time I made the structure similar to the Composing SwiftUI Gestures article but without the long press gesture.</p>
  
  <pre class="lang-swift prettyprint-override"><code>struct Example2: View {
      @State var viewState: CGSize = .zero
      @GestureState var dragState: DragState = .inactive
  
      enum DragState {
          case inactive
          case active(translation: CGSize)
  
          var translation: CGSize {
              switch self {
              case .active(translation: let translation):
                  return translation
              default:
                  return .zero
              }
          }
      }
  
      var body: some View {
          let dragGesture = DragGesture()
              .updating($dragState) { (value, state, _) in
                  state = .active(translation: value.translation)
          }.onEnded { (value) in
              self.viewState.width += value.translation.width
              self.viewState.height += value.translation.height
          }
  
          return Circle().foregroundColor(.red).frame(width: 20, height: 20)
              .offset(x: dragState.translation.width + viewState.width,
                      y: dragState.translation.height + viewState.height)
              .gesture(dragGesture)
      }
  }
  </code></pre>
  
  <h2>Main Question</h2>
  
  <p>Do either of these implementations do anything under the hood that I'm missing or are they exactly the same?</p>