RCTEventAnimation.m 936 B

1234567891011121314151617181920212223242526272829303132333435363738
  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/RCTEventAnimation.h>
  8. @implementation RCTEventAnimation
  9. {
  10. NSArray<NSString *> *_eventPath;
  11. }
  12. - (instancetype)initWithEventPath:(NSArray<NSString *> *)eventPath
  13. valueNode:(RCTValueAnimatedNode *)valueNode
  14. {
  15. if ((self = [super init])) {
  16. _eventPath = eventPath;
  17. _valueNode = valueNode;
  18. }
  19. return self;
  20. }
  21. - (void)updateWithEvent:(id<RCTEvent>)event
  22. {
  23. NSArray *args = event.arguments;
  24. // Supported events args are in the following order: viewTag, eventName, eventData.
  25. id currentValue = args[2];
  26. for (NSString *key in _eventPath) {
  27. currentValue = [currentValue valueForKey:key];
  28. }
  29. _valueNode.value = ((NSNumber *)currentValue).doubleValue;
  30. [_valueNode setNeedsUpdate];
  31. }
  32. @end