RCTAdditionAnimatedNode.m 821 B

1234567891011121314151617181920212223242526
  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/RCTAdditionAnimatedNode.h>
  8. @implementation RCTAdditionAnimatedNode
  9. - (void)performUpdate
  10. {
  11. [super performUpdate];
  12. NSArray<NSNumber *> *inputNodes = self.config[@"input"];
  13. if (inputNodes.count > 1) {
  14. RCTValueAnimatedNode *parent1 = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:inputNodes[0]];
  15. RCTValueAnimatedNode *parent2 = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:inputNodes[1]];
  16. if ([parent1 isKindOfClass:[RCTValueAnimatedNode class]] &&
  17. [parent2 isKindOfClass:[RCTValueAnimatedNode class]]) {
  18. self.value = parent1.value + parent2.value;
  19. }
  20. }
  21. }
  22. @end