d8436f79f6
* files reorganization (#432) * fix podspec * only include swift files * Fix broken readme paths (#433) * update links * fix french link * split skeleton debug to public and internal methods (#434) * Add build phase to execute SwiftLint (#435) * update tvOS tests * Refactor Extensions folder (#436) * Reorganize SkeletonAppearance (#437) * reorganize helpers and builders folders (#438) * Refactor flow and multilines (#439) * Reorganize collections folder (#440) * reorganize collections folder * update podspec * Refactor SkeletonView facade (#441) * reorganize collections folder * update podspec * refactor skeletonview facade * fix conflict * update iOS example * fix github workflows * update tvOS example project build settings
40 lines
1.4 KiB
Swift
40 lines
1.4 KiB
Swift
//
|
|
// SkeletonAnimationBuilder.swift
|
|
// SkeletonView-iOS
|
|
//
|
|
// Created by Juanpe Catalán on 17/11/2017.
|
|
// Copyright © 2017 SkeletonView. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
public typealias SkeletonLayerAnimation = (CALayer) -> CAAnimation
|
|
|
|
public class SkeletonAnimationBuilder {
|
|
|
|
public init() { }
|
|
|
|
public func makeSlidingAnimation(withDirection direction: GradientDirection, duration: CFTimeInterval = 1.5, autoreverses: Bool = false) -> SkeletonLayerAnimation {
|
|
{ _ in
|
|
let startPointAnim = CABasicAnimation(keyPath: #keyPath(CAGradientLayer.startPoint))
|
|
startPointAnim.fromValue = direction.startPoint.from
|
|
startPointAnim.toValue = direction.startPoint.to
|
|
|
|
let endPointAnim = CABasicAnimation(keyPath: #keyPath(CAGradientLayer.endPoint))
|
|
endPointAnim.fromValue = direction.endPoint.from
|
|
endPointAnim.toValue = direction.endPoint.to
|
|
|
|
let animGroup = CAAnimationGroup()
|
|
animGroup.animations = [startPointAnim, endPointAnim]
|
|
animGroup.duration = duration
|
|
animGroup.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn)
|
|
animGroup.repeatCount = .infinity
|
|
animGroup.autoreverses = autoreverses
|
|
animGroup.isRemovedOnCompletion = false
|
|
|
|
return animGroup
|
|
}
|
|
}
|
|
|
|
}
|