RCTModuloAnimatedNode.m 611 B

12345678910111213141516171819202122
  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/RCTModuloAnimatedNode.h>
  8. @implementation RCTModuloAnimatedNode
  9. - (void)performUpdate
  10. {
  11. [super performUpdate];
  12. NSNumber *inputNode = self.config[@"input"];
  13. NSNumber *modulus = self.config[@"modulus"];
  14. RCTValueAnimatedNode *parent = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:inputNode];
  15. const float m = modulus.floatValue;
  16. self.value = fmodf(fmodf(parent.value, m) + m, m);
  17. }
  18. @end