forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimationObserver.m
41 lines (31 loc) · 878 Bytes
/
AnimationObserver.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#import "AnimationObserver.h"
@implementation AnimationObserver {
NSMutableArray<RNNAnimationEndedBlock> *_animationEndedBlocks;
}
- (instancetype)init {
self = [super init];
_animationEndedBlocks = [NSMutableArray array];
return self;
}
+ (AnimationObserver *)sharedObserver {
static AnimationObserver *_sharedObserver = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedObserver = [[AnimationObserver alloc] init];
});
return _sharedObserver;
}
- (void)registerAnimationEndedBlock:(RNNAnimationEndedBlock)block {
[_animationEndedBlocks addObject:block];
}
- (void)beginAnimation {
_isAnimating = YES;
}
- (void)endAnimation {
_isAnimating = NO;
for (RNNAnimationEndedBlock block in _animationEndedBlocks) {
block();
}
[_animationEndedBlocks removeAllObjects];
}
@end