Commit 371f183a by Daniel Dahan

development: issue-194: fixed issue where hit test was failing after tranlation animation

parent aa90c37b
...@@ -254,6 +254,8 @@ extension CALayer { ...@@ -254,6 +254,8 @@ extension CALayer {
- Parameter animation: A CAAnimation instance. - Parameter animation: A CAAnimation instance.
*/ */
open func animate(animation: CAAnimation) { open func animate(animation: CAAnimation) {
animation.delegate = self
if let a = animation as? CABasicAnimation { if let a = animation as? CABasicAnimation {
a.fromValue = (presentation() ?? self).value(forKeyPath: a.keyPath!) a.fromValue = (presentation() ?? self).value(forKeyPath: a.keyPath!)
} }
...@@ -267,6 +269,40 @@ extension CALayer { ...@@ -267,6 +269,40 @@ extension CALayer {
} }
} }
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter animation: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
open func animationDidStop(_ animation: CAAnimation, finished flag: Bool) {
guard let a = animation as? CAPropertyAnimation else {
if let a = (animation as? CAAnimationGroup)?.animations {
for x in a {
animationDidStop(x, finished: true)
}
}
return
}
guard let b = a as? CABasicAnimation else {
return
}
guard let v = b.toValue else {
return
}
guard let k = b.keyPath else {
return
}
setValue(v, forKeyPath: k)
removeAnimation(forKey: k)
}
/// Manages the layout for the shape of the view instance. /// Manages the layout for the shape of the view instance.
open func layoutShape() { open func layoutShape() {
guard .none != shapePreset else { guard .none != shapePreset else {
......
...@@ -111,18 +111,18 @@ public struct Pulse { ...@@ -111,18 +111,18 @@ public struct Pulse {
layer.masksToBounds = !(.centerRadialBeyondBounds == animation || .radialBeyondBounds == animation) layer.masksToBounds = !(.centerRadialBeyondBounds == animation || .radialBeyondBounds == animation)
let w = view.width let w = view.bounds.width
let h = view.height let h = view.bounds.height
Motion.disable(animations: { [ Motion.disable(animations: { [
n = .center == animation ? w < h ? w : h : w < h ? h : w, n = .center == animation ? w < h ? w : h : w < h ? h : w,
frame = layer.bounds, bounds = layer.bounds,
animation = animation, animation = animation,
color = color, color = color,
opacity = opacity opacity = opacity
] in ] in
bLayer.frame = frame bLayer.frame = bounds
pLayer.bounds = CGRect(x: 0, y: 0, width: n, height: n) pLayer.bounds = CGRect(x: 0, y: 0, width: n, height: n)
switch animation { switch animation {
......
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