Skip to content

Commit

Permalink
Add simplified play() API to LottieView (airbnb#2178)
Browse files Browse the repository at this point in the history
  • Loading branch information
calda authored and iago849 committed Feb 8, 2024
1 parent 756361b commit e6a0438
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/Public/Animation/LottieView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,22 @@ public struct LottieView<Placeholder: View>: UIViewConfiguringSwiftUIView {
return copy
}

/// Returns a copy of this view that loops its animation whenever visible
// Returns a copy of this view playing once from the current frame to the end frame
public func play() -> Self {
play(loopMode: .playOnce)
}

/// Returns a copy of this view that loops its animation from the start to end whenever visible
public func looping() -> Self {
play(.fromProgress(0, toProgress: 1, loopMode: .loop))
}

/// Returns a copy of this view playing from the current frame to the end frame,
/// with the given `LottiePlaybackMode`.
public func play(loopMode: LottieLoopMode = .playOnce) -> Self {
play(.toProgress(1, loopMode: loopMode))
}

/// Returns a copy of this view playing with the given `LottiePlaybackMode`
public func play(_ playbackMode: LottiePlaybackMode) -> Self {
self.playbackMode(playbackMode)
Expand Down

0 comments on commit e6a0438

Please sign in to comment.