Skip to content

Commit

Permalink
Adds ability to not play the frame of the end marker (#1758) (#1772)
Browse files Browse the repository at this point in the history
  • Loading branch information
lennartstolz authored Oct 17, 2022
1 parent b3755b5 commit cb14050
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/Public/Animation/LottieAnimationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,15 @@ final public class LottieAnimationView: LottieAnimationViewBase {
/// - Parameter fromMarker: The start marker for the animation playback. If `nil` the
/// animation will start at the current progress.
/// - Parameter toMarker: The end marker for the animation playback.
/// - Parameter playEndMarkerFrame: A flag to determine whether or not to play the frame of the end marker. If the
/// end marker represents the end of the section to play, it should be to true. If the provided end marker
/// represents the beginning of the next section, it should be false.
/// - Parameter loopMode: The loop behavior of the animation. If `nil` the view's `loopMode` property will be used.
/// - Parameter completion: An optional completion closure to be called when the animation stops.
public func play(
fromMarker: String? = nil,
toMarker: String,
playEndMarkerFrame: Bool = true,
loopMode: LottieLoopMode? = nil,
completion: LottieCompletionBlock? = nil)
{
Expand All @@ -507,9 +511,10 @@ final public class LottieAnimationView: LottieAnimationViewBase {
fromTime = currentFrame
}

let playTo = playEndMarkerFrame ? CGFloat(to.frameTime) : CGFloat(to.frameTime) - 1
let context = AnimationContext(
playFrom: fromTime,
playTo: CGFloat(to.frameTime),
playTo: playTo,
closure: completion)
addNewAnimationForContext(context)
}
Expand Down

0 comments on commit cb14050

Please sign in to comment.