Skip to content

After applying the patch below, the animation will quickly flash back to the first frame from the last frame when it ends. #2670

@sunbohong

Description

@sunbohong
diff --git a/Example/Example/AnimationPreviewView.swift b/Example/Example/AnimationPreviewView.swift
index deef14a6..82bda8d8 100644
--- a/Example/Example/AnimationPreviewView.swift
+++ b/Example/Example/AnimationPreviewView.swift
@@ -62,12 +62,15 @@ struct AnimationPreviewView: View {
       .playbackMode(playbackMode)
       .animationDidFinish { completed in
         if completed {
+          animationView?.stop()
           animationPlaying = false
+          sliderValue = 0
         }
       }
       .configure { animationView in
         DispatchQueue.main.async {
           currentRenderingEngine = animationView.currentRenderingEngine
+          self.animationView = animationView
         }
       }
       .getRealtimeAnimationProgress(animationPlaying ? $sliderValue : nil)
@@ -114,11 +117,12 @@ struct AnimationPreviewView: View {
   @State private var animationPlaying = true
   @State private var sliderValue: AnimationProgressTime = 0
   @State private var currentURLIndex: Int
-  @State private var renderingEngine = RenderingEngineOption.automatic
-  @State private var loopMode = LottieLoopMode.loop
+  @State private var renderingEngine = RenderingEngineOption.mainThread
+  @State private var loopMode = LottieLoopMode.playOnce
   @State private var playFromProgress: AnimationProgressTime = 0
   @State private var playToProgress: AnimationProgressTime = 1
   @State private var currentRenderingEngine: RenderingEngine?
+  @State private var animationView: LottieAnimationView?
 
   /// Used for remote animations only, when more than one URL is provided we loop over the urls every 2 seconds.
   private let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions