lottie-ios 3.4.3 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.github/FUNDING.yml +0 -11
  2. package/Lottie.xcodeproj/project.pbxproj +58 -58
  3. package/Lottie.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +22 -0
  4. package/Lottie.xcworkspace/xcshareddata/swiftpm/Package.resolved +2 -2
  5. package/Lottie.xcworkspace/xcuserdata/calstephens.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  6. package/Sources/Private/CoreAnimation/Animations/CALayer+addAnimation.swift +1 -1
  7. package/Sources/Private/CoreAnimation/Animations/CombinedShapeAnimation.swift +10 -7
  8. package/Sources/Private/CoreAnimation/Animations/EllipseAnimation.swift +2 -2
  9. package/Sources/Private/CoreAnimation/Animations/GradientAnimations.swift +2 -2
  10. package/Sources/Private/CoreAnimation/Animations/LayerProperty.swift +2 -2
  11. package/Sources/Private/CoreAnimation/Animations/OpacityAnimation.swift +1 -1
  12. package/Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift +3 -3
  13. package/Sources/Private/CoreAnimation/Animations/ShapeAnimation.swift +16 -16
  14. package/Sources/Private/CoreAnimation/Animations/StarAnimation.swift +11 -11
  15. package/Sources/Private/CoreAnimation/Animations/StrokeAnimation.swift +4 -4
  16. package/Sources/Private/CoreAnimation/Animations/TransformAnimations.swift +13 -13
  17. package/Sources/Private/CoreAnimation/CoreAnimationLayer.swift +3 -3
  18. package/Sources/Private/CoreAnimation/Layers/AnimationLayer.swift +1 -1
  19. package/Sources/Private/CoreAnimation/Layers/CALayer+setupLayerHierarchy.swift +1 -1
  20. package/Sources/Private/CoreAnimation/Layers/LayerModel+makeAnimationLayer.swift +1 -1
  21. package/Sources/Private/CoreAnimation/Layers/PreCompLayer.swift +1 -1
  22. package/Sources/Private/CoreAnimation/Layers/RepeaterLayer.swift +9 -9
  23. package/Sources/Private/CoreAnimation/Layers/ShapeLayer.swift +1 -1
  24. package/Sources/Private/CoreAnimation/ValueProviderStore.swift +1 -1
  25. package/Sources/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.swift +2 -2
  26. package/Sources/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.swift +1 -1
  27. package/Sources/Private/MainThread/LayerContainers/CompLayers/SolidCompositionLayer.swift +2 -2
  28. package/Sources/Private/MainThread/LayerContainers/MainThreadAnimationLayer.swift +3 -3
  29. package/Sources/Private/MainThread/LayerContainers/Utility/LayerTransformNode.swift +10 -10
  30. package/Sources/Private/MainThread/NodeRenderSystem/Extensions/ItemsExtension.swift +1 -1
  31. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/ModifierNodes/TrimPathNode.swift +3 -3
  32. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/EllipseNode.swift +2 -2
  33. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/PolygonNode.swift +5 -5
  34. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/RectNode.swift +3 -3
  35. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/PathNodes/StarNode.swift +9 -9
  36. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderContainers/GroupNode.swift +14 -14
  37. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/FillNode.swift +2 -2
  38. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientFillNode.swift +3 -3
  39. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/GradientStrokeNode.swift +10 -10
  40. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/RenderNodes/StrokeNode.swift +14 -14
  41. package/Sources/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.swift +11 -11
  42. package/Sources/Private/Model/Keyframes/KeyframeData.swift +12 -12
  43. package/Sources/Private/Model/Layers/PreCompLayerModel.swift +3 -3
  44. package/Sources/Private/Model/Objects/DashPattern.swift +2 -2
  45. package/Sources/Private/Model/Objects/Marker.swift +4 -0
  46. package/Sources/Private/Model/Objects/Mask.swift +10 -8
  47. package/Sources/Private/Model/Objects/Transform.swift +39 -35
  48. package/Sources/Private/Model/ShapeItems/Ellipse.swift +6 -6
  49. package/Sources/Private/Model/ShapeItems/Fill.swift +6 -6
  50. package/Sources/Private/Model/ShapeItems/GradientFill.swift +15 -15
  51. package/Sources/Private/Model/ShapeItems/GradientStroke.swift +18 -18
  52. package/Sources/Private/Model/ShapeItems/Rectangle.swift +9 -9
  53. package/Sources/Private/Model/ShapeItems/Repeater.swift +37 -32
  54. package/Sources/Private/Model/ShapeItems/ShapeTransform.swift +34 -28
  55. package/Sources/Private/Model/ShapeItems/Star.swift +21 -21
  56. package/Sources/Private/Model/ShapeItems/Stroke.swift +9 -9
  57. package/Sources/Private/Model/ShapeItems/Trim.swift +9 -9
  58. package/Sources/Private/Model/Text/TextAnimator.swift +33 -33
  59. package/Sources/Private/Model/Text/TextDocument.swift +8 -8
  60. package/Sources/Private/RootAnimationLayer.swift +4 -4
  61. package/Sources/Private/Utility/Interpolatable/InterpolatableExtensions.swift +1 -1
  62. package/Sources/Private/Utility/Interpolatable/KeyframeGroup+Extensions.swift +4 -4
  63. package/Sources/Private/Utility/Primitives/ColorExtension.swift +7 -7
  64. package/Sources/Private/Utility/Primitives/VectorsExtensions.swift +29 -21
  65. package/Sources/{Private/Model/Animation.swift → Public/Animation/LottieAnimation.swift} +13 -5
  66. package/Sources/Public/Animation/{AnimationPublic.swift → LottieAnimationHelpers.swift} +32 -17
  67. package/Sources/Public/Animation/{AnimationView.swift → LottieAnimationView.swift} +68 -19
  68. package/Sources/Public/Animation/{AnimationViewInitializers.swift → LottieAnimationViewInitializers.swift} +6 -6
  69. package/Sources/Public/AnimationCache/AnimationCacheProvider.swift +3 -3
  70. package/Sources/Public/AnimationCache/LRUAnimationCache.swift +3 -3
  71. package/Sources/Public/DynamicProperties/AnimationKeypath.swift +3 -3
  72. package/Sources/Public/DynamicProperties/AnyValueProvider.swift +2 -2
  73. package/Sources/Public/DynamicProperties/ValueProviders/ColorValueProvider.swift +10 -10
  74. package/Sources/Public/DynamicProperties/ValueProviders/FloatValueProvider.swift +4 -4
  75. package/Sources/Public/DynamicProperties/ValueProviders/GradientValueProvider.swift +5 -5
  76. package/Sources/Public/DynamicProperties/ValueProviders/PointValueProvider.swift +2 -2
  77. package/Sources/Public/DynamicProperties/ValueProviders/SizeValueProvider.swift +2 -2
  78. package/Sources/Public/FontProvider/AnimationFontProvider.swift +1 -1
  79. package/Sources/Public/ImageProvider/AnimationImageProvider.swift +2 -2
  80. package/Sources/Public/Keyframes/Interpolatable.swift +17 -17
  81. package/Sources/Public/Keyframes/Keyframe.swift +10 -10
  82. package/Sources/Public/LottieConfiguration.swift +1 -1
  83. package/Sources/Public/Primitives/{Color.swift → LottieColor.swift} +10 -2
  84. package/Sources/Public/Primitives/Vectors.swift +18 -2
  85. package/Sources/Public/TextProvider/AnimationTextProvider.swift +1 -1
  86. package/Sources/Public/iOS/AnimatedButton.swift +26 -24
  87. package/Sources/Public/iOS/AnimatedControl.swift +6 -6
  88. package/Sources/Public/iOS/AnimatedSwitch.swift +16 -11
  89. package/Sources/Public/iOS/Compatibility/CompatibleAnimationView.swift +23 -8
  90. package/Sources/Public/iOS/{AnimationViewBase.swift → LottieAnimationViewBase.swift} +4 -4
  91. package/Sources/Public/iOS/UIColorExtension.swift +2 -2
  92. package/Sources/Public/macOS/{AnimationViewBase.macOS.swift → LottieAnimationViewBase.macOS.swift} +4 -4
  93. package/Tests/AnimationKeypathTests.swift +1 -1
  94. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~22UHuHHSTYh5NFeueXXSDdev_8VAbw8H8yl2ICssaC0vaCLj2G2CGZCjUMEyki9c-k-CecFJRyspvzJLiQTjUw== +0 -0
  95. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~4VqMqsI5lOfxRppnud6-VDWcNsU8J7VgFCJfW2dXPwOcAkvU-I8Um5yp9n0Zv6nr3VmcxYggaVMDFfR0U_vjKw== +1 -0
  96. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~6DmZhylL-XQx-O08NugyWINI0ugrLVgVOpbrdp0sT2tEqw-jVD2vvBWYRnYHALkM2_qP2yy-VoovSMzfYALY8A== +0 -0
  97. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~9dj3E5foFK2l_1CEpoRxToU1N6jCdhRVc5vhR10fHS938L9w8HxbiVCPGxYy5981O6M1yZsD4tHFbqBMbER4bQ== +0 -0
  98. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~Bys36bGK_YkCjRNoPMkq3R0OcyPNrVNka1Gz45ilbXJTqp9xAJexx6qKBh86_fm7OgBCO0WS2gJBy77DUUnOOA== +1 -0
  99. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~QJMKb50ZfaWLSHxBSGPlrzULLCqTlb_6W-X0N1-e5PfwCKjpYKOElImsOwgZKVK0cdyf-6u4Zp3mm3BfGQVQ9Q== +0 -0
  100. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~YyEdK1WNFTPo-R3Og2OWduKSikuFYneXurEZbyNLZeDmJLJkd7Ew8jNxy4mvgZw4f4Sikp4swEjJgVzXqhev5g== +1 -0
  101. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~bZd73QR3pWGndrn46_NXJw2dUT7WdBjkH5fdPZ7EnzlcZ9Ifv6WR14RKeWI9diiEjcRJE7ZOWqZ9fzf2vvTnLw== +0 -0
  102. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~baCaLsz8Sq-r6sHhJcZeowVdrnrIxKwDps5Q1Aq38G2AQ3HaopZ9m3A8IXtTFSiZGNiO2qnM9yH7iJfuzC5K0A== +0 -0
  103. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~iZXYCVJLYHKtR7eFHwefLiejC9CkRbBBSkkZmwfkiDEIdUKE4GgVkdDrcHry91RF7d9y7AuYovfGVp1-fuNg0g== +0 -0
  104. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~pTTJImrF4EktmVXGCigWBn7v6YlbH5eFCXIW35CW-iyypvzFMXXYYbQO1ly6Bf3u6CdaepZko-L9obC1mjigMA== +0 -0
  105. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~sVXLeN9UCp6IsOPeuoY76nF-bP-w2rBm61UYvs5XE3o5XhbM7itN2s1XD5i9COIaVMytmUFB-mvCLCqHfHWwpw== +0 -0
  106. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~t8Vsjx3tjPBGQIElMCvqzxLS0hDmBGuLa_CEiB64N2Vxp3qoUfNF0Sar84QnEDOKfyVF6c1KTn1QYg7fRJrk8g== +0 -0
  107. package/Tests/Artifacts/LottieTests.xcresult/Data/data.0~zUmPx8nRHLa8-g1WWSYYzveS_6qmBf-y4xyS-dHzD7c_xWwPZlsfKg8UngImNdn0gxGOBSRmCeXbYwWpLfj_Rg== +0 -0
  108. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~22UHuHHSTYh5NFeueXXSDdev_8VAbw8H8yl2ICssaC0vaCLj2G2CGZCjUMEyki9c-k-CecFJRyspvzJLiQTjUw== +0 -0
  109. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~4VqMqsI5lOfxRppnud6-VDWcNsU8J7VgFCJfW2dXPwOcAkvU-I8Um5yp9n0Zv6nr3VmcxYggaVMDFfR0U_vjKw== +0 -0
  110. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~6DmZhylL-XQx-O08NugyWINI0ugrLVgVOpbrdp0sT2tEqw-jVD2vvBWYRnYHALkM2_qP2yy-VoovSMzfYALY8A== +0 -0
  111. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~9dj3E5foFK2l_1CEpoRxToU1N6jCdhRVc5vhR10fHS938L9w8HxbiVCPGxYy5981O6M1yZsD4tHFbqBMbER4bQ== +0 -0
  112. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~Bys36bGK_YkCjRNoPMkq3R0OcyPNrVNka1Gz45ilbXJTqp9xAJexx6qKBh86_fm7OgBCO0WS2gJBy77DUUnOOA== +0 -0
  113. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~QJMKb50ZfaWLSHxBSGPlrzULLCqTlb_6W-X0N1-e5PfwCKjpYKOElImsOwgZKVK0cdyf-6u4Zp3mm3BfGQVQ9Q== +0 -0
  114. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~YyEdK1WNFTPo-R3Og2OWduKSikuFYneXurEZbyNLZeDmJLJkd7Ew8jNxy4mvgZw4f4Sikp4swEjJgVzXqhev5g== +0 -0
  115. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~bZd73QR3pWGndrn46_NXJw2dUT7WdBjkH5fdPZ7EnzlcZ9Ifv6WR14RKeWI9diiEjcRJE7ZOWqZ9fzf2vvTnLw== +0 -0
  116. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~baCaLsz8Sq-r6sHhJcZeowVdrnrIxKwDps5Q1Aq38G2AQ3HaopZ9m3A8IXtTFSiZGNiO2qnM9yH7iJfuzC5K0A== +0 -0
  117. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~iZXYCVJLYHKtR7eFHwefLiejC9CkRbBBSkkZmwfkiDEIdUKE4GgVkdDrcHry91RF7d9y7AuYovfGVp1-fuNg0g== +0 -0
  118. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~pTTJImrF4EktmVXGCigWBn7v6YlbH5eFCXIW35CW-iyypvzFMXXYYbQO1ly6Bf3u6CdaepZko-L9obC1mjigMA== +0 -0
  119. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~sVXLeN9UCp6IsOPeuoY76nF-bP-w2rBm61UYvs5XE3o5XhbM7itN2s1XD5i9COIaVMytmUFB-mvCLCqHfHWwpw== +0 -0
  120. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~t8Vsjx3tjPBGQIElMCvqzxLS0hDmBGuLa_CEiB64N2Vxp3qoUfNF0Sar84QnEDOKfyVF6c1KTn1QYg7fRJrk8g== +0 -0
  121. package/Tests/Artifacts/LottieTests.xcresult/Data/refs.0~zUmPx8nRHLa8-g1WWSYYzveS_6qmBf-y4xyS-dHzD7c_xWwPZlsfKg8UngImNdn0gxGOBSRmCeXbYwWpLfj_Rg== +0 -0
  122. package/Tests/Artifacts/LottieTests.xcresult/Info.plist +29 -0
  123. package/Tests/ParsingTests.swift +2 -2
  124. package/Tests/PerformanceTests.swift +9 -9
  125. package/Tests/SnapshotConfiguration.swift +4 -4
  126. package/Tests/SnapshotTests.swift +6 -6
  127. package/lottie-ios.podspec +1 -1
  128. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  //
2
- // AnimationView.swift
2
+ // LottieAnimationView.swift
3
3
  // lottie-swift
4
4
  //
5
5
  // Created by Brandon Withrow on 1/23/19.
@@ -37,7 +37,7 @@ public enum LottieBackgroundBehavior {
37
37
 
38
38
  /// The default background behavior, based on the rendering engine being used to play the animation.
39
39
  /// - Playing an animation using the Main Thread rendering engine comes with CPU overhead,
40
- /// so the animation should be paused or stopped when the `AnimationView` is not visible.
40
+ /// so the animation should be paused or stopped when the `LottieAnimationView` is not visible.
41
41
  /// - Playing an animation using the Core Animation rendering engine does not come with any
42
42
  /// CPU overhead, so these animations do not need to be paused in the background.
43
43
  public static func `default`(for renderingEngine: RenderingEngine) -> LottieBackgroundBehavior {
@@ -86,8 +86,16 @@ extension LottieLoopMode: Equatable {
86
86
 
87
87
  // MARK: - AnimationView
88
88
 
89
+ @available(*, deprecated, renamed: "LottieAnimationView", message: """
90
+ `AnimationView` has been renamed to `LottieAnimationView`, for consistency with \
91
+ the new `LottieAnimation` type. This notice will be removed in Lottie 4.0.
92
+ """)
93
+ public typealias AnimationView = LottieAnimationView
94
+
95
+ // MARK: - LottieAnimationView
96
+
89
97
  @IBDesignable
90
- final public class AnimationView: AnimationViewBase {
98
+ final public class LottieAnimationView: LottieAnimationViewBase {
91
99
 
92
100
  // MARK: Lifecycle
93
101
 
@@ -95,7 +103,7 @@ final public class AnimationView: AnimationViewBase {
95
103
 
96
104
  /// Initializes an AnimationView with an animation.
97
105
  public init(
98
- animation: Animation?,
106
+ animation: LottieAnimation?,
99
107
  imageProvider: AnimationImageProvider? = nil,
100
108
  textProvider: AnimationTextProvider = DefaultTextProvider(),
101
109
  fontProvider: AnimationFontProvider = DefaultFontProvider(),
@@ -153,7 +161,7 @@ final public class AnimationView: AnimationViewBase {
153
161
 
154
162
  // MARK: Public
155
163
 
156
- /// The configuration that this `AnimationView` uses when playing its animation
164
+ /// The configuration that this `LottieAnimationView` uses when playing its animation
157
165
  public let configuration: LottieConfiguration
158
166
 
159
167
  /// Value Providers that have been registered using `setValueProvider(_:keypath:)`
@@ -195,7 +203,7 @@ final public class AnimationView: AnimationViewBase {
195
203
  /// Sets the animation backing the animation view. Setting this will clear the
196
204
  /// view's contents, completion blocks and current state. The new animation will
197
205
  /// be loaded up and set to the beginning of its timeline.
198
- public var animation: Animation? {
206
+ public var animation: LottieAnimation? {
199
207
  didSet {
200
208
  makeAnimationLayer(usingEngine: configuration.renderingEngine)
201
209
  }
@@ -341,7 +349,7 @@ final public class AnimationView: AnimationViewBase {
341
349
  }
342
350
 
343
351
  /// When `true` the animation will play back at the framerate encoded in the
344
- /// `Animation` model. When `false` the animation will play at the framerate
352
+ /// `LottieAnimation` model. When `false` the animation will play at the framerate
345
353
  /// of the device.
346
354
  ///
347
355
  /// Defaults to false
@@ -513,6 +521,32 @@ final public class AnimationView: AnimationViewBase {
513
521
  addNewAnimationForContext(context)
514
522
  }
515
523
 
524
+ /// Plays the animation from a named marker to the end of the marker's duration.
525
+ ///
526
+ /// A marker is a point in time with an associated duration that is encoded into the
527
+ /// animation data and assigned a name.
528
+ ///
529
+ /// NOTE: If marker is not found the play command will exit.
530
+ ///
531
+ /// - Parameter marker: The start marker for the animation playback.
532
+ /// - Parameter loopMode: The loop behavior of the animation. If `nil` the view's `loopMode` property will be used.
533
+ /// - Parameter completion: An optional completion closure to be called when the animation stops.
534
+ public func play(
535
+ marker: String,
536
+ loopMode: LottieLoopMode? = nil,
537
+ completion: LottieCompletionBlock? = nil)
538
+ {
539
+ guard let from = animation?.markerMap?[marker] else {
540
+ return
541
+ }
542
+
543
+ play(
544
+ fromFrame: from.frameTime,
545
+ toFrame: from.frameTime + from.durationFrameTime,
546
+ loopMode: loopMode,
547
+ completion: completion)
548
+ }
549
+
516
550
  /// Stops the animation and resets the view to its start frame.
517
551
  ///
518
552
  /// The completion closure will be called with `false`
@@ -533,7 +567,7 @@ final public class AnimationView: AnimationViewBase {
533
567
  animationLayer?.reloadImages()
534
568
  }
535
569
 
536
- /// Forces the AnimationView to redraw its contents.
570
+ /// Forces the LottieAnimationView to redraw its contents.
537
571
  public func forceDisplayUpdate() {
538
572
  animationLayer?.forceDisplayUpdate()
539
573
  }
@@ -625,7 +659,7 @@ final public class AnimationView: AnimationViewBase {
625
659
  }
626
660
  }
627
661
 
628
- /// Converts a CGRect from the AnimationView's coordinate space into the
662
+ /// Converts a CGRect from the LottieAnimationView's coordinate space into the
629
663
  /// coordinate space of the layer found at Keypath.
630
664
  ///
631
665
  /// If no layer is found, nil is returned
@@ -646,7 +680,7 @@ final public class AnimationView: AnimationViewBase {
646
680
  return animationLayer.convert(rect, to: sublayer)
647
681
  }
648
682
 
649
- /// Converts a CGPoint from the AnimationView's coordinate space into the
683
+ /// Converts a CGPoint from the LottieAnimationView's coordinate space into the
650
684
  /// coordinate space of the layer found at Keypath.
651
685
  ///
652
686
  /// If no layer is found, nil is returned
@@ -713,6 +747,21 @@ final public class AnimationView: AnimationViewBase {
713
747
  return animation.frameTime(forMarker: named)
714
748
  }
715
749
 
750
+ /// Markers are a way to describe a point in time and a duration by a key name.
751
+ ///
752
+ /// Markers are encoded into animation JSON. By using markers a designer can mark
753
+ /// playback points for a developer to use without having to worry about keeping
754
+ /// track of animation frames. If the animation file is updated, the developer
755
+ /// does not need to update playback code.
756
+ ///
757
+ /// - Returns: The duration frame time for the marker, or `nil` if no marker found.
758
+ public func durationFrameTime(forMarker named: String) -> AnimationFrameTime? {
759
+ guard let animation = animation else {
760
+ return nil
761
+ }
762
+ return animation.durationFrameTime(forMarker: named)
763
+ }
764
+
716
765
  // MARK: Internal
717
766
 
718
767
  var animationLayer: RootAnimationLayer? = nil
@@ -721,7 +770,7 @@ final public class AnimationView: AnimationViewBase {
721
770
  @IBInspectable var animationName: String? {
722
771
  didSet {
723
772
  self.animation = animationName.flatMap {
724
- Animation.named($0, animationCache: nil)
773
+ LottieAnimation.named($0, animationCache: nil)
725
774
  }
726
775
  }
727
776
  }
@@ -925,12 +974,12 @@ final public class AnimationView: AnimationViewBase {
925
974
 
926
975
  // MARK: Fileprivate
927
976
 
928
- /// Context describing the animation that is currently playing in this `AnimationView`
977
+ /// Context describing the animation that is currently playing in this `LottieAnimationView`
929
978
  /// - When non-nil, an animation is currently playing in this view. Otherwise,
930
979
  /// the view is paused on a specific frame.
931
980
  fileprivate var animationContext: AnimationContext?
932
981
 
933
- fileprivate var _activeAnimationName: String = AnimationView.animationName
982
+ fileprivate var _activeAnimationName: String = LottieAnimationView.animationName
934
983
  fileprivate var animationID = 0
935
984
 
936
985
  fileprivate var waitingToPlayAnimation = false
@@ -982,7 +1031,7 @@ final public class AnimationView: AnimationViewBase {
982
1031
  currentFrame = CGFloat(animation.startFrame)
983
1032
  }
984
1033
 
985
- fileprivate func makeMainThreadAnimationLayer(for animation: Animation) -> MainThreadAnimationLayer {
1034
+ fileprivate func makeMainThreadAnimationLayer(for animation: LottieAnimation) -> MainThreadAnimationLayer {
986
1035
  MainThreadAnimationLayer(
987
1036
  animation: animation,
988
1037
  imageProvider: imageProvider.cachedImageProvider,
@@ -991,7 +1040,7 @@ final public class AnimationView: AnimationViewBase {
991
1040
  logger: logger)
992
1041
  }
993
1042
 
994
- fileprivate func makeCoreAnimationLayer(for animation: Animation) -> CoreAnimationLayer? {
1043
+ fileprivate func makeCoreAnimationLayer(for animation: LottieAnimation) -> CoreAnimationLayer? {
995
1044
  do {
996
1045
  let coreAnimationLayer = try CoreAnimationLayer(
997
1046
  animation: animation,
@@ -1024,7 +1073,7 @@ final public class AnimationView: AnimationViewBase {
1024
1073
  }
1025
1074
  }
1026
1075
 
1027
- fileprivate func makeAutomaticEngineLayer(for animation: Animation) -> CoreAnimationLayer? {
1076
+ fileprivate func makeAutomaticEngineLayer(for animation: LottieAnimation) -> CoreAnimationLayer? {
1028
1077
  do {
1029
1078
  // Attempt to set up the Core Animation layer. This can either throw immediately in `init`,
1030
1079
  // or throw an error later in `CALayer.display()` that will be reported in `didSetUpAnimation`.
@@ -1135,7 +1184,7 @@ final public class AnimationView: AnimationViewBase {
1135
1184
  /// this step lets us avoid building the animations twice (once paused
1136
1185
  /// and once again playing)
1137
1186
  /// - This method should only be called immediately before setting up another
1138
- /// animation -- otherwise this AnimationView could be put in an inconsistent state.
1187
+ /// animation -- otherwise this LottieAnimationView could be put in an inconsistent state.
1139
1188
  fileprivate func removeCurrentAnimationIfNecessary() {
1140
1189
  switch currentRenderingEngine {
1141
1190
  case .mainThread:
@@ -1144,7 +1193,7 @@ final public class AnimationView: AnimationViewBase {
1144
1193
  // We still need to remove the `animationContext`, since it should only be present
1145
1194
  // when an animation is actually playing. Without this calling `removeCurrentAnimationIfNecessary()`
1146
1195
  // and then setting the animation to a specific paused frame would put this
1147
- // `AnimationView` in an inconsistent state.
1196
+ // `LottieAnimationView` in an inconsistent state.
1148
1197
  animationContext = nil
1149
1198
  }
1150
1199
  }
@@ -1208,7 +1257,7 @@ final public class AnimationView: AnimationViewBase {
1208
1257
  }
1209
1258
 
1210
1259
  animationID = animationID + 1
1211
- _activeAnimationName = AnimationView.animationName + String(animationID)
1260
+ _activeAnimationName = LottieAnimationView.animationName + String(animationID)
1212
1261
 
1213
1262
  if let coreAnimationLayer = animationlayer as? CoreAnimationLayer {
1214
1263
  var animationContext = animationContext
@@ -7,7 +7,7 @@
7
7
 
8
8
  import Foundation
9
9
 
10
- extension AnimationView {
10
+ extension LottieAnimationView {
11
11
 
12
12
  // MARK: Lifecycle
13
13
 
@@ -26,7 +26,7 @@ extension AnimationView {
26
26
  animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache,
27
27
  configuration: LottieConfiguration = .shared)
28
28
  {
29
- let animation = Animation.named(name, bundle: bundle, subdirectory: nil, animationCache: animationCache)
29
+ let animation = LottieAnimation.named(name, bundle: bundle, subdirectory: nil, animationCache: animationCache)
30
30
  let provider = imageProvider ?? BundleImageProvider(bundle: bundle, searchPath: nil)
31
31
  self.init(animation: animation, imageProvider: provider, configuration: configuration)
32
32
  }
@@ -42,7 +42,7 @@ extension AnimationView {
42
42
  animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache,
43
43
  configuration: LottieConfiguration = .shared)
44
44
  {
45
- let animation = Animation.filepath(filePath, animationCache: animationCache)
45
+ let animation = LottieAnimation.filepath(filePath, animationCache: animationCache)
46
46
  let provider = imageProvider ??
47
47
  FilepathImageProvider(filepath: URL(fileURLWithPath: filePath).deletingLastPathComponent().path)
48
48
  self.init(animation: animation, imageProvider: provider, configuration: configuration)
@@ -57,7 +57,7 @@ extension AnimationView {
57
57
  public convenience init(
58
58
  url: URL,
59
59
  imageProvider: AnimationImageProvider? = nil,
60
- closure: @escaping AnimationView.DownloadClosure,
60
+ closure: @escaping LottieAnimationView.DownloadClosure,
61
61
  animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache,
62
62
  configuration: LottieConfiguration = .shared)
63
63
  {
@@ -67,7 +67,7 @@ extension AnimationView {
67
67
  } else {
68
68
  self.init(animation: nil, imageProvider: imageProvider, configuration: configuration)
69
69
 
70
- Animation.loadedFrom(url: url, closure: { animation in
70
+ LottieAnimation.loadedFrom(url: url, closure: { animation in
71
71
  if let animation = animation {
72
72
  self.animation = animation
73
73
  closure(nil)
@@ -91,7 +91,7 @@ extension AnimationView {
91
91
  animationCache: AnimationCacheProvider? = LRUAnimationCache.sharedCache,
92
92
  configuration: LottieConfiguration = .shared)
93
93
  {
94
- let animation = Animation.asset(name, bundle: bundle, animationCache: animationCache)
94
+ let animation = LottieAnimation.asset(name, bundle: bundle, animationCache: animationCache)
95
95
  let provider = imageProvider ?? BundleImageProvider(bundle: bundle, searchPath: nil)
96
96
  self.init(animation: animation, imageProvider: provider, configuration: configuration)
97
97
  }
@@ -7,15 +7,15 @@
7
7
 
8
8
  import Foundation
9
9
  /// `AnimationCacheProvider` is a protocol that describes an Animation Cache.
10
- /// Animation Cache is used when loading `Animation` models. Using an Animation Cache
10
+ /// Animation Cache is used when loading `LottieAnimation` models. Using an Animation Cache
11
11
  /// can increase performance when loading an animation multiple times.
12
12
  ///
13
13
  /// Lottie comes with a prebuilt LRU Animation Cache.
14
14
  public protocol AnimationCacheProvider {
15
15
 
16
- func animation(forKey: String) -> Animation?
16
+ func animation(forKey: String) -> LottieAnimation?
17
17
 
18
- func setAnimation(_ animation: Animation, forKey: String)
18
+ func setAnimation(_ animation: LottieAnimation, forKey: String)
19
19
 
20
20
  func clearCache()
21
21
 
@@ -31,7 +31,7 @@ public class LRUAnimationCache: AnimationCacheProvider {
31
31
  lruList.removeAll()
32
32
  }
33
33
 
34
- public func animation(forKey: String) -> Animation? {
34
+ public func animation(forKey: String) -> LottieAnimation? {
35
35
  guard let animation = cacheMap[forKey] else {
36
36
  return nil
37
37
  }
@@ -42,7 +42,7 @@ public class LRUAnimationCache: AnimationCacheProvider {
42
42
  return animation
43
43
  }
44
44
 
45
- public func setAnimation(_ animation: Animation, forKey: String) {
45
+ public func setAnimation(_ animation: LottieAnimation, forKey: String) {
46
46
  cacheMap[forKey] = animation
47
47
  lruList.append(forKey)
48
48
  if lruList.count > cacheSize {
@@ -55,7 +55,7 @@ public class LRUAnimationCache: AnimationCacheProvider {
55
55
 
56
56
  // MARK: Fileprivate
57
57
 
58
- fileprivate var cacheMap: [String: Animation] = [:]
58
+ fileprivate var cacheMap: [String: LottieAnimation] = [:]
59
59
  fileprivate var lruList: [String] = []
60
60
 
61
61
  }
@@ -8,11 +8,11 @@
8
8
  import Foundation
9
9
 
10
10
  /// `AnimationKeypath` is an object that describes a keypath search for nodes in the
11
- /// animation JSON. `AnimationKeypath` matches views and properties inside of `AnimationView`
12
- /// to their backing `Animation` model by name.
11
+ /// animation JSON. `AnimationKeypath` matches views and properties inside of `LottieAnimationView`
12
+ /// to their backing `LottieAnimation` model by name.
13
13
  ///
14
14
  /// A keypath can be used to set properties on an existing animation, or can be validated
15
- /// with an existing `Animation`.
15
+ /// with an existing `LottieAnimation`.
16
16
  ///
17
17
  /// `AnimationKeypath` can describe a specific object, or can use wildcards for fuzzy matching
18
18
  /// of objects. Acceptable wildcards are either "*" (star) or "**" (double star).
@@ -11,8 +11,8 @@ import Foundation
11
11
  // MARK: - AnyValueProvider
12
12
 
13
13
  /// `AnyValueProvider` is a protocol that return animation data for a property at a
14
- /// given time. Every frame an `AnimationView` queries all of its properties and asks
15
- /// if their ValueProvider has an update. If it does the AnimationView will read the
14
+ /// given time. Every frame a `LottieAnimationView` queries all of its properties and asks
15
+ /// if their ValueProvider has an update. If it does the LottieAnimationView will read the
16
16
  /// property and update that portion of the animation.
17
17
  ///
18
18
  /// Value Providers can be used to dynamically set animation properties at run time.
@@ -16,12 +16,12 @@ public final class ColorValueProvider: ValueProvider {
16
16
  /// Initializes with a block provider
17
17
  public init(block: @escaping ColorValueBlock) {
18
18
  self.block = block
19
- color = Color(r: 0, g: 0, b: 0, a: 1)
19
+ color = LottieColor(r: 0, g: 0, b: 0, a: 1)
20
20
  keyframes = nil
21
21
  }
22
22
 
23
23
  /// Initializes with a single color.
24
- public init(_ color: Color) {
24
+ public init(_ color: LottieColor) {
25
25
  self.color = color
26
26
  block = nil
27
27
  keyframes = nil
@@ -29,20 +29,20 @@ public final class ColorValueProvider: ValueProvider {
29
29
  }
30
30
 
31
31
  /// Initializes with multiple colors, with timing information
32
- public init(_ keyframes: [Keyframe<Color>]) {
32
+ public init(_ keyframes: [Keyframe<LottieColor>]) {
33
33
  self.keyframes = keyframes
34
- color = Color(r: 0, g: 0, b: 0, a: 1)
34
+ color = LottieColor(r: 0, g: 0, b: 0, a: 1)
35
35
  block = nil
36
36
  hasUpdate = true
37
37
  }
38
38
 
39
39
  // MARK: Public
40
40
 
41
- /// Returns a Color for a CGColor(Frame Time)
42
- public typealias ColorValueBlock = (CGFloat) -> Color
41
+ /// Returns a LottieColor for a CGColor(Frame Time)
42
+ public typealias ColorValueBlock = (CGFloat) -> LottieColor
43
43
 
44
44
  /// The color value of the provider.
45
- public var color: Color {
45
+ public var color: LottieColor {
46
46
  didSet {
47
47
  hasUpdate = true
48
48
  }
@@ -51,10 +51,10 @@ public final class ColorValueProvider: ValueProvider {
51
51
  // MARK: ValueProvider Protocol
52
52
 
53
53
  public var valueType: Any.Type {
54
- Color.self
54
+ LottieColor.self
55
55
  }
56
56
 
57
- public var storage: ValueProviderStorage<Color> {
57
+ public var storage: ValueProviderStorage<LottieColor> {
58
58
  if let block = block {
59
59
  return .closure { frame in
60
60
  self.hasUpdate = false
@@ -80,5 +80,5 @@ public final class ColorValueProvider: ValueProvider {
80
80
  private var hasUpdate = true
81
81
 
82
82
  private var block: ColorValueBlock?
83
- private var keyframes: [Keyframe<Color>]?
83
+ private var keyframes: [Keyframe<LottieColor>]?
84
84
  }
@@ -40,18 +40,18 @@ public final class FloatValueProvider: ValueProvider {
40
40
  // MARK: ValueProvider Protocol
41
41
 
42
42
  public var valueType: Any.Type {
43
- Vector1D.self
43
+ LottieVector1D.self
44
44
  }
45
45
 
46
- public var storage: ValueProviderStorage<Vector1D> {
46
+ public var storage: ValueProviderStorage<LottieVector1D> {
47
47
  if let block = block {
48
48
  return .closure { frame in
49
49
  self.hasUpdate = false
50
- return Vector1D(Double(block(frame)))
50
+ return LottieVector1D(Double(block(frame)))
51
51
  }
52
52
  } else {
53
53
  hasUpdate = false
54
- return .singleValue(Vector1D(Double(float)))
54
+ return .singleValue(LottieVector1D(Double(float)))
55
55
  }
56
56
  }
57
57
 
@@ -26,7 +26,7 @@ public final class GradientValueProvider: ValueProvider {
26
26
 
27
27
  /// Initializes with an array of colors.
28
28
  public init(
29
- _ colors: [Color],
29
+ _ colors: [LottieColor],
30
30
  locations: [Double] = [])
31
31
  {
32
32
  self.colors = colors
@@ -37,13 +37,13 @@ public final class GradientValueProvider: ValueProvider {
37
37
 
38
38
  // MARK: Public
39
39
 
40
- /// Returns a [Color] for a CGFloat(Frame Time).
41
- public typealias ColorsValueBlock = (CGFloat) -> [Color]
40
+ /// Returns a [LottieColor] for a CGFloat(Frame Time).
41
+ public typealias ColorsValueBlock = (CGFloat) -> [LottieColor]
42
42
  /// Returns a [Double](Color locations) for a CGFloat(Frame Time).
43
43
  public typealias ColorLocationsBlock = (CGFloat) -> [Double]
44
44
 
45
45
  /// The colors values of the provider.
46
- public var colors: [Color] {
46
+ public var colors: [LottieColor] {
47
47
  didSet {
48
48
  updateValueArray()
49
49
  hasUpdate = true
@@ -93,7 +93,7 @@ public final class GradientValueProvider: ValueProvider {
93
93
  private var locationsBlock: ColorLocationsBlock?
94
94
  private var value: [Double] = []
95
95
 
96
- private func value(from colors: [Color], locations: [Double]) -> [Double] {
96
+ private func value(from colors: [LottieColor], locations: [Double]) -> [Double] {
97
97
  var colorValues = [Double]()
98
98
  var alphaValues = [Double]()
99
99
  var shouldAddAlphaValues = false
@@ -39,10 +39,10 @@ public final class PointValueProvider: ValueProvider {
39
39
  // MARK: ValueProvider Protocol
40
40
 
41
41
  public var valueType: Any.Type {
42
- Vector3D.self
42
+ LottieVector3D.self
43
43
  }
44
44
 
45
- public var storage: ValueProviderStorage<Vector3D> {
45
+ public var storage: ValueProviderStorage<LottieVector3D> {
46
46
  if let block = block {
47
47
  return .closure { frame in
48
48
  self.hasUpdate = false
@@ -40,10 +40,10 @@ public final class SizeValueProvider: ValueProvider {
40
40
  // MARK: ValueProvider Protocol
41
41
 
42
42
  public var valueType: Any.Type {
43
- Vector3D.self
43
+ LottieVector3D.self
44
44
  }
45
45
 
46
- public var storage: ValueProviderStorage<Vector3D> {
46
+ public var storage: ValueProviderStorage<LottieVector3D> {
47
47
  if let block = block {
48
48
  return .closure { frame in
49
49
  self.hasUpdate = false
@@ -12,7 +12,7 @@ import Foundation
12
12
 
13
13
  // MARK: - AnimationFontProvider
14
14
 
15
- /// Font provider is a protocol that is used to supply fonts to `AnimationView`.
15
+ /// Font provider is a protocol that is used to supply fonts to `LottieAnimationView`.
16
16
  ///
17
17
  public protocol AnimationFontProvider {
18
18
  func fontFor(family: String, size: CGFloat) -> CTFont?
@@ -8,10 +8,10 @@
8
8
  import CoreGraphics
9
9
  import Foundation
10
10
 
11
- /// Image provider is a protocol that is used to supply images to `AnimationView`.
11
+ /// Image provider is a protocol that is used to supply images to `LottieAnimationView`.
12
12
  ///
13
13
  /// Some animations require a reference to an image. The image provider loads and
14
- /// provides those images to the `AnimationView`. Lottie includes a couple of
14
+ /// provides those images to the `LottieAnimationView`. Lottie includes a couple of
15
15
  /// prebuilt Image Providers that supply images from a Bundle, or from a FilePath.
16
16
  ///
17
17
  /// Additionally custom Image Providers can be made to load images from a URL,
@@ -168,11 +168,11 @@ extension CGPoint: SpatialInterpolatable {
168
168
  }
169
169
  }
170
170
 
171
- // MARK: - Color + Interpolatable
171
+ // MARK: - LottieColor + Interpolatable
172
172
 
173
- extension Color: Interpolatable {
174
- public func interpolate(to: Color, amount: CGFloat) -> Color {
175
- Color(
173
+ extension LottieColor: Interpolatable {
174
+ public func interpolate(to: LottieColor, amount: CGFloat) -> LottieColor {
175
+ LottieColor(
176
176
  r: r.interpolate(to: to.r, amount: amount),
177
177
  g: g.interpolate(to: to.g, amount: amount),
178
178
  b: b.interpolate(to: to.b, amount: amount),
@@ -180,23 +180,23 @@ extension Color: Interpolatable {
180
180
  }
181
181
  }
182
182
 
183
- // MARK: - Vector1D + Interpolatable
183
+ // MARK: - LottieVector1D + Interpolatable
184
184
 
185
- extension Vector1D: Interpolatable {
186
- public func interpolate(to: Vector1D, amount: CGFloat) -> Vector1D {
185
+ extension LottieVector1D: Interpolatable {
186
+ public func interpolate(to: LottieVector1D, amount: CGFloat) -> LottieVector1D {
187
187
  value.interpolate(to: to.value, amount: amount).vectorValue
188
188
  }
189
189
  }
190
190
 
191
- // MARK: - Vector2D + SpatialInterpolatable
191
+ // MARK: - LottieVector2D + SpatialInterpolatable
192
192
 
193
- extension Vector2D: SpatialInterpolatable {
193
+ extension LottieVector2D: SpatialInterpolatable {
194
194
  public func interpolate(
195
- to: Vector2D,
195
+ to: LottieVector2D,
196
196
  amount: CGFloat,
197
197
  spatialOutTangent: CGPoint?,
198
198
  spatialInTangent: CGPoint?)
199
- -> Vector2D
199
+ -> LottieVector2D
200
200
  {
201
201
  pointValue.interpolate(
202
202
  to: to.pointValue,
@@ -207,15 +207,15 @@ extension Vector2D: SpatialInterpolatable {
207
207
  }
208
208
  }
209
209
 
210
- // MARK: - Vector3D + SpatialInterpolatable
210
+ // MARK: - LottieVector3D + SpatialInterpolatable
211
211
 
212
- extension Vector3D: SpatialInterpolatable {
212
+ extension LottieVector3D: SpatialInterpolatable {
213
213
  public func interpolate(
214
- to: Vector3D,
214
+ to: LottieVector3D,
215
215
  amount: CGFloat,
216
216
  spatialOutTangent: CGPoint?,
217
217
  spatialInTangent: CGPoint?)
218
- -> Vector3D
218
+ -> LottieVector3D
219
219
  {
220
220
  if spatialInTangent != nil || spatialOutTangent != nil {
221
221
  // TODO Support third dimension spatial interpolation
@@ -225,13 +225,13 @@ extension Vector3D: SpatialInterpolatable {
225
225
  spatialOutTangent: spatialOutTangent,
226
226
  spatialInTangent: spatialInTangent)
227
227
 
228
- return Vector3D(
228
+ return LottieVector3D(
229
229
  x: point.x,
230
230
  y: point.y,
231
231
  z: CGFloat(z.interpolate(to: to.z, amount: amount)))
232
232
  }
233
233
 
234
- return Vector3D(
234
+ return LottieVector3D(
235
235
  x: x.interpolate(to: to.x, amount: amount),
236
236
  y: y.interpolate(to: to.y, amount: amount),
237
237
  z: z.interpolate(to: to.z, amount: amount))
@@ -13,8 +13,8 @@ public final class Keyframe<T> {
13
13
  /// Initialize a value-only keyframe with no time data.
14
14
  public init(
15
15
  _ value: T,
16
- spatialInTangent: Vector3D? = nil,
17
- spatialOutTangent: Vector3D? = nil)
16
+ spatialInTangent: LottieVector3D? = nil,
17
+ spatialOutTangent: LottieVector3D? = nil)
18
18
  {
19
19
  self.value = value
20
20
  time = 0
@@ -30,10 +30,10 @@ public final class Keyframe<T> {
30
30
  value: T,
31
31
  time: AnimationFrameTime,
32
32
  isHold: Bool = false,
33
- inTangent: Vector2D? = nil,
34
- outTangent: Vector2D? = nil,
35
- spatialInTangent: Vector3D? = nil,
36
- spatialOutTangent: Vector3D? = nil)
33
+ inTangent: LottieVector2D? = nil,
34
+ outTangent: LottieVector2D? = nil,
35
+ spatialInTangent: LottieVector3D? = nil,
36
+ spatialOutTangent: LottieVector3D? = nil)
37
37
  {
38
38
  self.value = value
39
39
  self.time = time
@@ -53,14 +53,14 @@ public final class Keyframe<T> {
53
53
  /// A hold keyframe freezes interpolation until the next keyframe that is not a hold.
54
54
  public let isHold: Bool
55
55
  /// The in tangent for the time interpolation curve.
56
- public let inTangent: Vector2D?
56
+ public let inTangent: LottieVector2D?
57
57
  /// The out tangent for the time interpolation curve.
58
- public let outTangent: Vector2D?
58
+ public let outTangent: LottieVector2D?
59
59
 
60
60
  /// The spatial in tangent of the vector.
61
- public let spatialInTangent: Vector3D?
61
+ public let spatialInTangent: LottieVector3D?
62
62
  /// The spatial out tangent of the vector.
63
- public let spatialOutTangent: Vector3D?
63
+ public let spatialOutTangent: LottieVector3D?
64
64
  }
65
65
 
66
66
  // MARK: Equatable
@@ -15,7 +15,7 @@ public struct LottieConfiguration: Hashable {
15
15
  }
16
16
 
17
17
  /// The global configuration of Lottie,
18
- /// which applies to all `AnimationView`s by default.
18
+ /// which applies to all `LottieAnimationView`s by default.
19
19
  public static var shared = LottieConfiguration()
20
20
 
21
21
  /// The rendering engine implementation to use when displaying an animation