title: Swipe back gesture like in without navigationView in SwiftUI
body: <p>I am trying to create a simply game in SwiftUI and im trying to get a swipe back gesture similar to that on navigationView but without putting my view inside a navigationView. Since this is a game, adding naviagationView will look out of place.</p>
  <p>This is what I have so far:</p>
  <pre><code>struct SwipingView : View {
    @State private var dragAmount = CGSize.zero
    @GestureState private var position = CGSize.zero
    func addToPosition(translation:CGSize) -&gt; CGSize {
      return CGSize(width: dragAmount.width + translation.width, height: dragAmount.height + translation.height)
    }
  
    var body: some View{
      return ZStack(){
        Rectangle().fill(Color.red).frame(width: 100, height:400).scaleEffect(x:5,y:1,anchor: .leading)
          .offset(x: 190)
          .offset(x: addToPosition(translation: position).width )
          .gesture(
            DragGesture(minimumDistance: 20)
              .updating(self.$position){ value, state, translation in
                state = value.translation
              }
              .onEnded{ value in
                if value.translation.width &gt; 50 {
                  guard position.width + self.addToPosition(translation: CGSize(width:330, height:0)).width &lt; 330-1 else {
                    return print(&quot;too far right&quot;)
                  }
                  self.dragAmount = self.addToPosition(translation: CGSize(width:330, height:0))
                } else {
                  guard position.width + self.addToPosition(translation: CGSize(width:-330, height:0)).width &gt; -330-1 else {
                    return print(&quot;too far left&quot;)
                  }
                  self.dragAmount = self.addToPosition(translation: CGSize(width:-330, height:0))
                }
              }
          )
      }.animation(Animation.linear)
    }
  }
  </code></pre>
  <p>I'm still new to swift so there is likely something obvious im missing even though I've looked through stack overflow and couldn't find exactly what im looking for.</p>
  <p>This is what it looks like. As you can see, I can swipe the view away from anywhere on the view, but I'd like to <strong>only</strong> swipe away on the left edge or even just the first 5% on the left.</p>
  <p><a href="https://i.stack.imgur.com/pLoM0.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pLoM0.gif" alt="enter image description here" /></a></p>