RCTStyleAnimatedNode.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <React/RCTStyleAnimatedNode.h>
  8. #import <React/RCTAnimationUtils.h>
  9. #import <React/RCTValueAnimatedNode.h>
  10. #import <React/RCTTransformAnimatedNode.h>
  11. @implementation RCTStyleAnimatedNode
  12. {
  13. NSMutableDictionary<NSString *, NSObject *> *_propsDictionary;
  14. }
  15. - (instancetype)initWithTag:(NSNumber *)tag
  16. config:(NSDictionary<NSString *, id> *)config
  17. {
  18. if ((self = [super initWithTag:tag config:config])) {
  19. _propsDictionary = [NSMutableDictionary new];
  20. }
  21. return self;
  22. }
  23. - (NSDictionary *)propsDictionary
  24. {
  25. return _propsDictionary;
  26. }
  27. - (void)performUpdate
  28. {
  29. [super performUpdate];
  30. NSDictionary<NSString *, NSNumber *> *style = self.config[@"style"];
  31. [style enumerateKeysAndObjectsUsingBlock:^(NSString *property, NSNumber *nodeTag, __unused BOOL *stop) {
  32. RCTAnimatedNode *node = [self.parentNodes objectForKey:nodeTag];
  33. if (node) {
  34. if ([node isKindOfClass:[RCTValueAnimatedNode class]]) {
  35. RCTValueAnimatedNode *parentNode = (RCTValueAnimatedNode *)node;
  36. [self->_propsDictionary setObject:@(parentNode.value) forKey:property];
  37. } else if ([node isKindOfClass:[RCTTransformAnimatedNode class]]) {
  38. RCTTransformAnimatedNode *parentNode = (RCTTransformAnimatedNode *)node;
  39. [self->_propsDictionary addEntriesFromDictionary:parentNode.propsDictionary];
  40. }
  41. }
  42. }];
  43. }
  44. @end