title: SwiftUI: Stop an Animation that Repeats Forever
body: <p><strong>I would like to have a 'badge' of sorts on the screen and when conditions are met, it will bounce from normal size to bigger and back to normal repeatedly until the conditions are no longer met. I cannot seem to get the badge to stop 'bouncing', though.</strong> Once it starts, it's unstoppable.</p>
  
  <p><strong>What I've tried:</strong>
  I have tried using a few animations, but they can be classified as animations that use 'repeatForever' to achieve the desired effect and those that do not. For example:</p>
  
  <p><code>Animation.default.repeatForever(autoreverses: true)</code></p>
  
  <p>and </p>
  
  <p><code>Animation.spring(response: 1, dampingFraction: 0, blendDuration: 1)</code>(Setting damping to 0 makes it go forever)</p>
  
  <p>followed by swapping it out with .animation(nil). Doesn't seem to work. Does anyone have any ideas? Thank you so very much ahead of time! Here is the code to reproduce it: </p>
  
  <pre><code>struct theProblem: View {
      @State var active: Bool = false
  
      var body: some View {
          Circle()
              .scaleEffect( active ? 1.08: 1)
              .animation( active ? Animation.default.repeatForever(autoreverses: true): nil )
              .frame(width: 100, height: 100)
              .onTapGesture {
                  self.active = !self.active
  
          }
      }
  }
  </code></pre>