Commit 76395176 by Daniel Dahan

fixed animation issue, where animations were not persisting their end state

parent debf975c
...@@ -97,7 +97,7 @@ class AppViewController: NavigationViewController { ...@@ -97,7 +97,7 @@ class AppViewController: NavigationViewController {
sideNavigationViewController?.enabled = true sideNavigationViewController?.enabled = true
// Position the menuBackdropLayer for the animation when closing. // Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer.animate(MaterialAnimation.scale(1, duration: 0.25)) menuBackdropLayer.animate(MaterialAnimation.scale(1))
menuView.menu.close() menuView.menu.close()
image = UIImage(named: "ic_add_white") image = UIImage(named: "ic_add_white")
...@@ -110,7 +110,7 @@ class AppViewController: NavigationViewController { ...@@ -110,7 +110,7 @@ class AppViewController: NavigationViewController {
self.menuBackdropLayer.frame = self.menuView.frame self.menuBackdropLayer.frame = self.menuView.frame
self.menuBackdropLayer.shape = .Circle self.menuBackdropLayer.shape = .Circle
} }
menuBackdropLayer.animate(MaterialAnimation.scale(30, duration: 0.25)) menuBackdropLayer.animate(MaterialAnimation.scale(30))
menuBackdropLayer.hidden = false menuBackdropLayer.hidden = false
menuView.menu.open() { (v: UIView) in menuView.menu.open() { (v: UIView) in
......
...@@ -348,12 +348,8 @@ public class MaterialButton : UIButton { ...@@ -348,12 +348,8 @@ public class MaterialButton : UIButton {
if interrupted. if interrupted.
*/ */
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) { public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation { if anim is CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup { } else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! { for x in a.animations! {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
......
...@@ -280,14 +280,8 @@ public class MaterialLayer : CAShapeLayer { ...@@ -280,14 +280,8 @@ public class MaterialLayer : CAShapeLayer {
if interrupted. if interrupted.
*/ */
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) { public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation { if anim is CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
MaterialAnimation.animationDisabled { [unowned self] in
self.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
// removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup { } else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! { for x in a.animations! {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
......
...@@ -387,12 +387,8 @@ public class MaterialView : UIView { ...@@ -387,12 +387,8 @@ public class MaterialView : UIView {
if interrupted. if interrupted.
*/ */
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) { public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation { if anim is CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup { } else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! { for x in a.animations! {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
......
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