mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-17 16:07:44 +03:00
Fixes for examples
This commit is contained in:
parent
d9a5b27e94
commit
bac14c1e85
@ -24,11 +24,8 @@ class BasicAnimation: Animation {
|
||||
|
||||
weak var node: Node? {
|
||||
didSet {
|
||||
node?.animations.append(self)
|
||||
if let group = node as? Group {
|
||||
for node in group.contents {
|
||||
node.animations.append(self)
|
||||
}
|
||||
if !(self is CombineAnimation || self is AnimationSequence || self is EmptyAnimation) {
|
||||
node?.animations.append(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -104,6 +101,8 @@ class BasicAnimation: Animation {
|
||||
}
|
||||
|
||||
removeFunc?()
|
||||
node?.animations.removeAll { $0 === self }
|
||||
nodeRenderer?.freeLayer()
|
||||
}
|
||||
|
||||
override open func pause() {
|
||||
@ -115,6 +114,8 @@ class BasicAnimation: Animation {
|
||||
}
|
||||
|
||||
removeFunc?()
|
||||
node?.animations.removeAll { $0 === self }
|
||||
nodeRenderer?.freeLayer()
|
||||
}
|
||||
|
||||
override func state() -> AnimationState {
|
||||
|
@ -143,9 +143,9 @@ class AnimationProducer {
|
||||
}
|
||||
|
||||
// MARK: - Sequence animation
|
||||
func addAnimationSequence(_ animationSequnce: Animation,
|
||||
func addAnimationSequence(_ animationSequence: Animation,
|
||||
_ context: AnimationContext) {
|
||||
guard let sequence = animationSequnce as? AnimationSequence else {
|
||||
guard let sequence = animationSequence as? AnimationSequence else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -27,21 +27,17 @@ internal class AnimationSequence: BasicAnimation {
|
||||
open override func stop() {
|
||||
super.stop()
|
||||
|
||||
guard let active = animations.first(where: { $0.isActive() }) else {
|
||||
return
|
||||
animations.forEach { animation in
|
||||
animation.stop()
|
||||
}
|
||||
|
||||
active.stop()
|
||||
}
|
||||
|
||||
open override func pause() {
|
||||
super.pause()
|
||||
|
||||
guard let active = animations.first(where: { $0.isActive() }) else {
|
||||
return
|
||||
animations.forEach { animation in
|
||||
animation.pause()
|
||||
}
|
||||
|
||||
active.pause()
|
||||
}
|
||||
|
||||
open override func play() {
|
||||
|
@ -116,6 +116,7 @@ extension AnimationProducer {
|
||||
func addCombineAnimation(_ combineAnimation: Animation, _ context: AnimationContext) {
|
||||
guard let combine = combineAnimation as? CombineAnimation,
|
||||
let renderer = combine.nodeRenderer,
|
||||
let node = combine.node,
|
||||
let view = renderer.view else {
|
||||
return
|
||||
}
|
||||
@ -176,6 +177,7 @@ extension AnimationProducer {
|
||||
}
|
||||
|
||||
combine.removeFunc = {
|
||||
node.animations.removeAll { $0 === combine }
|
||||
animations.forEach { animation in
|
||||
animation.removeFunc?()
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ func addMorphingAnimation(_ animation: BasicAnimation, _ context: AnimationConte
|
||||
let animationId = animation.ID
|
||||
layer.add(generatedAnimation, forKey: animationId)
|
||||
animation.removeFunc = { [weak layer] in
|
||||
shape.animations.removeAll { $0 === animation }
|
||||
layer?.removeAnimation(forKey: animationId)
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,15 @@ func addOpacityAnimation(_ animation: BasicAnimation, _ context: AnimationContex
|
||||
node.opacityVar.value = opacityAnimation.getVFunc()(1.0)
|
||||
}
|
||||
|
||||
CATransaction.begin()
|
||||
CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions)
|
||||
renderer.layer?.animationLayer.opacity = Float(node.opacity)
|
||||
CATransaction.commit()
|
||||
|
||||
if !animation.paused {
|
||||
animation.removeFunc?()
|
||||
}
|
||||
|
||||
renderer.freeLayer()
|
||||
|
||||
if !animation.cycled &&
|
||||
@ -62,6 +71,7 @@ func addOpacityAnimation(_ animation: BasicAnimation, _ context: AnimationContex
|
||||
let animationId = animation.ID
|
||||
layer.add(generatedAnimation, forKey: animationId)
|
||||
animation.removeFunc = { [weak layer] in
|
||||
node.animations.removeAll { $0 === animation }
|
||||
layer?.removeAnimation(forKey: animationId)
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,15 @@ func addTransformAnimation(_ animation: BasicAnimation, _ context: AnimationCont
|
||||
node.placeVar.value = transformAnimation.getVFunc()(1.0)
|
||||
}
|
||||
|
||||
CATransaction.begin()
|
||||
CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions)
|
||||
renderer.layer?.animationLayer.transform = CATransform3DMakeAffineTransform(node.place.toCG())
|
||||
CATransaction.commit()
|
||||
|
||||
if !animation.paused {
|
||||
animation.removeFunc?()
|
||||
}
|
||||
|
||||
renderer.freeLayer()
|
||||
|
||||
if !animation.cycled &&
|
||||
@ -68,6 +77,7 @@ func addTransformAnimation(_ animation: BasicAnimation, _ context: AnimationCont
|
||||
let animationId = animation.ID
|
||||
layer.add(generatedAnimation, forKey: animationId)
|
||||
animation.removeFunc = { [weak layer] in
|
||||
node.animations.removeAll { $0 === animation }
|
||||
layer?.removeAnimation(forKey: animationId)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user