Skip to content

Commit

Permalink
development: fixed issue that when view was rotated it would not calc…
Browse files Browse the repository at this point in the history
…ulate the cornerRadius correctly
  • Loading branch information
Daniel Dahan committed Dec 2, 2016
1 parent 5930fa6 commit 402084c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 4 additions & 8 deletions Sources/iOS/Material+CALayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,10 @@ extension CALayer {
- Parameter animation: A CAAnimation instance.
*/
open func animate(animation: CAAnimation) {
if #available(iOS 10, *) {
animation.delegate = self
}
animation.delegate = self

if let a = animation as? CABasicAnimation {
a.fromValue = (nil == presentation() ? self : presentation()!).value(forKeyPath: a.keyPath!)
a.fromValue = (presentation() ?? self).value(forKeyPath: a.keyPath!)
}

if let a = animation as? CAPropertyAnimation {
Expand Down Expand Up @@ -320,7 +318,7 @@ extension CALayer {
}

if .circle == shapePreset {
cornerRadius = width / 2
cornerRadius = bounds.size.width / 2
}
}

Expand All @@ -343,6 +341,4 @@ extension CALayer {
}

@available(iOS 10, *)
extension CALayer: CAAnimationDelegate {

}
extension CALayer: CAAnimationDelegate {}
8 changes: 4 additions & 4 deletions Sources/iOS/MotionBasic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ extension Motion {
public static func rotateY(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationY)

if let v: CGFloat = angle {
if let v = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v: CGFloat = rotation {
} else if let v = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
}

Expand All @@ -212,9 +212,9 @@ extension Motion {
public static func rotateZ(angle: CGFloat? = nil, rotation: CGFloat? = nil, duration: CFTimeInterval? = nil) -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: .rotationZ)

if let v: CGFloat = angle {
if let v = angle {
animation.toValue = (CGFloat(M_PI) * v / 180) as NSNumber
} else if let v: CGFloat = rotation {
} else if let v = rotation {
animation.toValue = (CGFloat(M_PI * 2) * v) as NSNumber
}

Expand Down

0 comments on commit 402084c

Please sign in to comment.