Skip to content

Commit

Permalink
feat: change signature makeSlidingAnimation method
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanpe committed Nov 18, 2017
1 parent 1862179 commit 9ef6d3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

```
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions Sources/SkeletonAnimationBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 9ef6d3e

Please sign in to comment.