|
21 | 21 | #import <UIKit/UIKit.h>
|
22 | 22 | #import <objc/runtime.h>
|
23 | 23 |
|
| 24 | +// Returns the set of animatable key paths supported by MDMMotionAnimator's implicit animations. |
| 25 | +static NSSet<MDMAnimatableKeyPath> *AllAnimatableKeyPaths(void) { |
| 26 | + static NSSet *animatableKeyPaths = nil; |
| 27 | + static dispatch_once_t onceToken; |
| 28 | + dispatch_once(&onceToken, ^{ |
| 29 | + animatableKeyPaths = [NSSet setWithArray:@[MDMKeyPathBackgroundColor, |
| 30 | + MDMKeyPathBounds, |
| 31 | + MDMKeyPathCornerRadius, |
| 32 | + MDMKeyPathHeight, |
| 33 | + MDMKeyPathOpacity, |
| 34 | + MDMKeyPathPosition, |
| 35 | + MDMKeyPathRotation, |
| 36 | + MDMKeyPathScale, |
| 37 | + MDMKeyPathShadowOffset, |
| 38 | + MDMKeyPathShadowOpacity, |
| 39 | + MDMKeyPathShadowRadius, |
| 40 | + MDMKeyPathStrokeStart, |
| 41 | + MDMKeyPathStrokeEnd, |
| 42 | + MDMKeyPathWidth, |
| 43 | + MDMKeyPathX, |
| 44 | + MDMKeyPathY]]; |
| 45 | + }); |
| 46 | + return animatableKeyPaths; |
| 47 | +} |
| 48 | + |
24 | 49 | @interface MDMActionContext: NSObject
|
25 | 50 | @property(nonatomic, readonly) NSArray<MDMImplicitAction *> *interceptedActions;
|
26 | 51 | @end
|
@@ -83,9 +108,9 @@ @interface MDMLayerDelegate: NSObject <CALayerDelegate>
|
83 | 108 | MDMActionContext *context = [sActionContext lastObject];
|
84 | 109 | NSCAssert(context != nil, @"MotionAnimator action method invoked out of implicit scope.");
|
85 | 110 |
|
86 |
| - if (context == nil) { |
87 |
| - // Graceful handling of invalid state on non-debug builds for if our context is nil invokes our |
88 |
| - // original implementation: |
| 111 | + BOOL shouldAnimateWithAnimator = [AllAnimatableKeyPaths() containsObject:event]; |
| 112 | + if (context == nil || !shouldAnimateWithAnimator) { |
| 113 | + // Fall through to the original CALayer implementation. |
89 | 114 | return ((id<CAAction>(*)(id, SEL, NSString *))sOriginalActionForKeyLayerImp)
|
90 | 115 | (layer, _cmd, event);
|
91 | 116 | }
|
|
0 commit comments