2016-06-09 17:34:41 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-06-09 17:34:41 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-06-09 17:34:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import "RCTTransformAnimatedNode.h"
|
|
|
|
#import "RCTValueAnimatedNode.h"
|
|
|
|
|
|
|
|
@implementation RCTTransformAnimatedNode
|
|
|
|
{
|
2016-11-28 19:09:46 +00:00
|
|
|
NSMutableDictionary<NSString *, NSObject *> *_propsDictionary;
|
2016-06-09 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithTag:(NSNumber *)tag
|
|
|
|
config:(NSDictionary<NSString *, id> *)config;
|
|
|
|
{
|
|
|
|
if ((self = [super initWithTag:tag config:config])) {
|
2016-11-28 19:09:46 +00:00
|
|
|
_propsDictionary = [NSMutableDictionary new];
|
2016-06-09 17:34:41 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2016-11-28 19:09:46 +00:00
|
|
|
- (NSDictionary *)propsDictionary
|
2016-06-09 17:34:41 +00:00
|
|
|
{
|
2016-11-28 19:09:46 +00:00
|
|
|
return _propsDictionary;
|
2016-06-09 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)performUpdate
|
|
|
|
{
|
|
|
|
[super performUpdate];
|
|
|
|
|
2016-08-02 21:23:18 +00:00
|
|
|
NSArray<NSDictionary *> *transformConfigs = self.config[@"transforms"];
|
2017-01-27 02:14:40 +00:00
|
|
|
NSMutableArray<NSDictionary *> *transform = [NSMutableArray arrayWithCapacity:transformConfigs.count];
|
2016-08-02 21:23:18 +00:00
|
|
|
for (NSDictionary *transformConfig in transformConfigs) {
|
2016-08-07 07:44:09 +00:00
|
|
|
NSString *type = transformConfig[@"type"];
|
2016-11-01 04:04:54 +00:00
|
|
|
NSString *property = transformConfig[@"property"];
|
2017-01-27 02:14:40 +00:00
|
|
|
NSNumber *value;
|
2016-11-01 04:04:54 +00:00
|
|
|
if ([type isEqualToString: @"animated"]) {
|
|
|
|
NSNumber *nodeTag = transformConfig[@"nodeTag"];
|
2017-10-23 20:16:24 +00:00
|
|
|
RCTAnimatedNode *node = [self.parentNodes objectForKey:nodeTag];
|
2016-11-28 19:09:46 +00:00
|
|
|
if (![node isKindOfClass:[RCTValueAnimatedNode class]]) {
|
2016-11-01 04:04:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-06-09 17:34:41 +00:00
|
|
|
RCTValueAnimatedNode *parentNode = (RCTValueAnimatedNode *)node;
|
2017-01-27 02:14:40 +00:00
|
|
|
value = @(parentNode.value);
|
2016-11-01 04:04:54 +00:00
|
|
|
} else {
|
2017-01-27 02:14:40 +00:00
|
|
|
value = transformConfig[@"value"];
|
2016-06-09 17:34:41 +00:00
|
|
|
}
|
2017-01-27 02:14:40 +00:00
|
|
|
[transform addObject:@{property: value}];
|
2016-08-02 21:23:18 +00:00
|
|
|
}
|
|
|
|
|
2017-01-27 02:14:40 +00:00
|
|
|
_propsDictionary[@"transform"] = transform;
|
2016-06-09 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|