diff --git a/README.md b/README.md index a0f8c47f..48f883c9 100755 --- a/README.md +++ b/README.md @@ -249,9 +249,9 @@ view.showAnimatedSkeleton { (layer) -> CAAnimation in Today, you can create **sliding animations** for gradients, deciding the **direction** and setting the **duration** of the animation (default = 1.5s). ```swift -// func makeSlidingAnimation(with direction: GradientDirection, duration: CFTimeInterval = 1.5) -> SkeletonLayerAnimation +// func makeSlidingAnimation(withDirection direction: GradientDirection, duration: CFTimeInterval = 1.5) -> SkeletonLayerAnimation -let animation = SkeletonAnimationBuilder().makeSlidingAnimation(with: .leftToRight) +let animation = SkeletonAnimationBuilder().makeSlidingAnimation(withDirection: .leftToRight) view.showAnimatedGradientSkeleton(usingGradient: gradient, animation: animation) ``` @@ -267,9 +267,9 @@ view.showAnimatedGradientSkeleton(usingGradient: gradient, animation: animation) | .topLeftBottomRight | ![](Assets/sliding_topLeft_to_bottomRight.gif) | .bottomRightTopLeft | ![](Assets/sliding_bottomRight_to_topLeft.gif) -> **TRICK!** +> **๐Ÿ˜‰ TRICK!** Exist another way to create sliding animations, just using this shortcut: ->>```let animation = GradientDirection.leftToRight.slidingAnimation``` +>>```let animation = GradientDirection.leftToRight.slidingAnimation()``` ### ๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Hierarchy diff --git a/Sources/SkeletonAnimationBuilder.swift b/Sources/SkeletonAnimationBuilder.swift index e5168fba..a7718958 100644 --- a/Sources/SkeletonAnimationBuilder.swift +++ b/Sources/SkeletonAnimationBuilder.swift @@ -18,8 +18,8 @@ public enum GradientDirection { case topLeftBottomRight case bottomRightTopLeft - public var slidingAnimation: SkeletonLayerAnimation { - return SkeletonAnimationBuilder().makeSlidingAnimation(with: self) + public func slidingAnimation(duration: CFTimeInterval = 1.5) -> SkeletonLayerAnimation { + return SkeletonAnimationBuilder().makeSlidingAnimation(withDirection: self, duration: duration) } var startPoint: GradientAnimationPoint { @@ -62,7 +62,7 @@ public class SkeletonAnimationBuilder { public init() { } - public func makeSlidingAnimation(with direction: GradientDirection, duration: CFTimeInterval = 1.5) -> SkeletonLayerAnimation { + public func makeSlidingAnimation(withDirection direction: GradientDirection, duration: CFTimeInterval = 1.5) -> SkeletonLayerAnimation { return { layer in let startPointAnim = CABasicAnimation(keyPath: #keyPath(CAGradientLayer.startPoint))