mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 13:15:35 +03:00
Ability to declare animation before scene attached to a view. fixes #54
This commit is contained in:
parent
146756f094
commit
058c4634da
@ -3,6 +3,8 @@ let animationProducer = AnimationProducer()
|
||||
|
||||
class AnimationProducer {
|
||||
|
||||
var storedAnimations = [Node: BasicAnimation]()
|
||||
|
||||
func addAnimation(animation: BasicAnimation, withoutDelay: Bool = false) {
|
||||
|
||||
if animation.delay > 0.0 && !withoutDelay {
|
||||
@ -24,6 +26,7 @@ class AnimationProducer {
|
||||
}
|
||||
|
||||
guard let macawView = nodesMap.getView(node) else {
|
||||
storedAnimations[node] = animation
|
||||
return
|
||||
}
|
||||
|
||||
@ -176,4 +179,19 @@ class AnimationProducer {
|
||||
private func executeCompletion(emptyAnimation: BasicAnimation) {
|
||||
emptyAnimation.completion?()
|
||||
}
|
||||
|
||||
func addStoredAnimations(node: Node) {
|
||||
if let animation = storedAnimations[node] {
|
||||
addAnimation(animation)
|
||||
storedAnimations.removeValueForKey(node)
|
||||
}
|
||||
|
||||
guard let group = node as? Group else {
|
||||
return
|
||||
}
|
||||
|
||||
group.contents.forEach { child in
|
||||
addStoredAnimations(child)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class MacawView: UIView {
|
||||
if let cache = animationCache {
|
||||
self.renderer = RenderUtils.createNodeRenderer(node, context: context, animationCache: cache)
|
||||
}
|
||||
animationProducer.addStoredAnimations(node)
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +44,7 @@ public class MacawView: UIView {
|
||||
if let cache = self.animationCache {
|
||||
self.renderer = RenderUtils.createNodeRenderer(node, context: context, animationCache: cache)
|
||||
}
|
||||
animationProducer.addStoredAnimations(node)
|
||||
|
||||
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(MacawView.handlePan))
|
||||
let rotationRecognizer = UIRotationGestureRecognizer(target: self, action: #selector(MacawView.handleRotation))
|
||||
|
Loading…
Reference in New Issue
Block a user