Commit 398021c6 by Daniel Dahan

updated Motion+Array and Motion+CALayer

parent 1127ed5a
...@@ -29,37 +29,77 @@ ...@@ -29,37 +29,77 @@
import UIKit import UIKit
internal extension Array { internal extension Array {
func get(_ index: Int) -> Element? { /**
if index < count { Retrieves the element at the given index if it exists.
return self[index] - 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 { internal extension Array where Element: ExprNode {
func getCGFloat(_ index: Int) -> CGFloat? { /**
if let s = get(index) as? NumberNode { Retrieves the element at the given index if it exists
return CGFloat(s.value) 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? { Retrieves the element at the given index if it exists
if let s = get(index) as? NumberNode { as a Double.
return Double(s.value) - 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? { Retrieves the element at the given index if it exists
if let s = get(index) as? NumberNode { as a Float.
return s.value - 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? { Retrieves the element at the given index if it exists
if let s = get(index) as? VariableNode, let f = Bool(s.name) { as a Bool.
return f - 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 @@ ...@@ -28,20 +28,22 @@
import UIKit import UIKit
@available(iOS 10, *)
extension CALayer: CAAnimationDelegate {}
internal extension CALayer { internal extension CALayer {
// return all animations running by this layer. /// Retrieves all currently running animations for the layer.
// the returned value is mutable var animations: [(String, CAAnimation)] {
var animations: [(String, CAAnimation)] { guard let keys = animationKeys() else {
if let keys = animationKeys() { return []
return keys.map { return ($0, self.animation(forKey: $0)!.copy() as! CAAnimation) } }
return keys.map {
return ($0, self.animation(forKey: $0)!.copy() as! CAAnimation)
}
} }
return []
}
} }
@available(iOS 10, *)
extension CALayer: CAAnimationDelegate {}
extension CALayer { extension CALayer {
/** /**
A function that accepts CAAnimation objects and executes them on the A function that accepts CAAnimation objects and executes them on the
...@@ -77,6 +79,10 @@ extension CALayer { ...@@ -77,6 +79,10 @@ extension CALayer {
} }
} }
/**
Executed when an animation has started.
- Parameter _ anim: A CAAnimation.
*/
public func animationDidStart(_ anim: 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