Commit 398021c6 by Daniel Dahan

updated Motion+Array and Motion+CALayer

parent 1127ed5a
......@@ -29,37 +29,77 @@
import UIKit
internal extension Array {
func get(_ index: Int) -> Element? {
if index < count {
return self[index]
/**
Retrieves the element at the given index if it exists.
- Parameter _ index: An Int.
- Returns: An optional Element value.
*/
func get(_ index: Int) -> Element? {
if index < count {
return self[index]
}
return nil
}
return nil
}
}
internal extension Array where Element: ExprNode {
func getCGFloat(_ index: Int) -> CGFloat? {
if let s = get(index) as? NumberNode {
return CGFloat(s.value)
/**
Retrieves the element at the given index if it exists
as a CGFloat.
- Parameter _ index: An Int.
- Returns: An optional CGFloat value.
*/
func getCGFloat(_ index: Int) -> CGFloat? {
guard let s = get(index) as? NumberNode else {
return nil
}
return CGFloat(s.value)
}
return nil
}
func getDouble(_ index: Int) -> Double? {
if let s = get(index) as? NumberNode {
return Double(s.value)
/**
Retrieves the element at the given index if it exists
as a Double.
- Parameter _ index: An Int.
- Returns: An optional Double value.
*/
func getDouble(_ index: Int) -> Double? {
guard let s = get(index) as? NumberNode else {
return nil
}
return Double(s.value)
}
return nil
}
func getFloat(_ index: Int) -> Float? {
if let s = get(index) as? NumberNode {
return s.value
/**
Retrieves the element at the given index if it exists
as a Float.
- Parameter _ index: An Int.
- Returns: An optional Float value.
*/
func getFloat(_ index: Int) -> Float? {
guard let s = get(index) as? NumberNode else {
return nil
}
return s.value
}
return nil
}
func getBool(_ index: Int) -> Bool? {
if let s = get(index) as? VariableNode, let f = Bool(s.name) {
return f
/**
Retrieves the element at the given index if it exists
as a Bool.
- Parameter _ index: An Int.
- Returns: An optional Bool value.
*/
func getBool(_ index: Int) -> Bool? {
guard let s = get(index) as? VariableNode else {
return nil
}
guard let f = Bool(s.name) else {
return nil
}
return f
}
return nil
}
}
......@@ -28,20 +28,22 @@
import UIKit
@available(iOS 10, *)
extension CALayer: CAAnimationDelegate {}
internal extension CALayer {
// return all animations running by this layer.
// the returned value is mutable
var animations: [(String, CAAnimation)] {
if let keys = animationKeys() {
return keys.map { return ($0, self.animation(forKey: $0)!.copy() as! CAAnimation) }
/// Retrieves all currently running animations for the layer.
var animations: [(String, CAAnimation)] {
guard let keys = animationKeys() else {
return []
}
return keys.map {
return ($0, self.animation(forKey: $0)!.copy() as! CAAnimation)
}
}
return []
}
}
@available(iOS 10, *)
extension CALayer: CAAnimationDelegate {}
extension CALayer {
/**
A function that accepts CAAnimation objects and executes them on the
......@@ -77,6 +79,10 @@ extension CALayer {
}
}
/**
Executed when an animation has started.
- Parameter _ anim: A CAAnimation.
*/
public func animationDidStart(_ anim: CAAnimation) {}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment