Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Touch up the block animations docs. (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey authored Nov 8, 2017
1 parent 94b86e6 commit 64d6c31
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/private/MDMBlockAnimations.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
#import <UIKit/UIKit.h>
#import <objc/runtime.h>

static IMP sOriginalActionForLayerImp = NULL;

@interface MDMActionContext: NSObject
@property(nonatomic, readonly) NSArray<MDMImplicitAction *> *interceptedActions;
@end

// The original UIView method implementation of actionForLayer:forKey:.
static IMP sOriginalActionForLayerImp = NULL;
static NSMutableArray<MDMActionContext *> *sActionContext = nil;

@implementation MDMImplicitAction

- (instancetype)initWithLayer:(CALayer *)layer
Expand Down Expand Up @@ -67,8 +69,6 @@ - (void)addActionForLayer:(CALayer *)layer

@end

static NSMutableArray *sActionContext = nil;

static id<CAAction> ActionForLayer(id self, SEL _cmd, CALayer *layer, NSString *event) {
NSCAssert([NSStringFromSelector(_cmd) isEqualToString:
NSStringFromSelector(@selector(actionForLayer:forKey:))],
Expand All @@ -87,7 +87,7 @@ - (void)addActionForLayer:(CALayer *)layer
// We don't have access to the "to" value of our animation here, so we unfortunately can't
// calculate additive values if the animator is configured as such. So, to support additive
// animations, we queue up the modified actions and then add them all at the end of our
// MDMAnimateBlock invocation.
// MDMAnimateImplicitly invocation.
id initialValue = [layer valueForKeyPath:event];
[context addActionForLayer:layer keyPath:event withInitialValue:initialValue];
return [NSNull null];
Expand All @@ -98,8 +98,8 @@ - (void)addActionForLayer:(CALayer *)layer
return nil;
}

// This method can be called recursively, so we maintain a recursive context stack in the scope of
// this method. Note that this is absolutely not thread safe, but neither is Core Animation.
// This method can be called recursively, so we maintain a context stack in the scope of this
// method. Note that this is absolutely not thread safe, but neither is Core Animation.
if (!sActionContext) {
sActionContext = [NSMutableArray array];
}
Expand All @@ -110,7 +110,7 @@ - (void)addActionForLayer:(CALayer *)layer

if (sOriginalActionForLayerImp == nil) {
// Swap the original UIView implementation with our own so that we can intercept all
// actionForLayer:forKey: events. All events will be
// actionForLayer:forKey: events.
sOriginalActionForLayerImp = method_setImplementation(method, (IMP)ActionForLayer);
}

Expand Down

0 comments on commit 64d6c31

Please sign in to comment.