mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
cc3f9a7538
Summary: fixes #23875 [ios,android][fixes] incorrect behavior of `Animated.modulo` Use the same formula as used in js: `mod(a,m)=>(a % m + m) % m` (https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedModulo.js#L35) Native implementation of `Animated.modulo` was different from what was used in javascript, more details available here: https://github.com/facebook/react-native/issues/23875 [iOS] [Fixed] incorrect behavior of Animated.modulo [Android] [Fixed] incorrect behavior of Animated.modulo Pull Request resolved: https://github.com/facebook/react-native/pull/23973 Differential Revision: D14502697 Pulled By: cpojer fbshipit-source-id: befef2b99ae758f98459caaadc8ebdbbd547e69a
23 lines
606 B
Objective-C
23 lines
606 B
Objective-C
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTModuloAnimatedNode.h"
|
|
|
|
@implementation RCTModuloAnimatedNode
|
|
|
|
- (void)performUpdate
|
|
{
|
|
[super performUpdate];
|
|
NSNumber *inputNode = self.config[@"input"];
|
|
NSNumber *modulus = self.config[@"modulus"];
|
|
RCTValueAnimatedNode *parent = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:inputNode];
|
|
const float m = modulus.floatValue;
|
|
self.value = fmodf(fmodf(parent.value, m) + m, m);
|
|
}
|
|
|
|
@end
|