mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix native implementation of Animated.modulo (#23973)
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
This commit is contained in:
committed by
Facebook Github Bot
parent
f541c34067
commit
cc3f9a7538
@@ -29,7 +29,8 @@ import com.facebook.react.bridge.ReadableMap;
|
||||
public void update() {
|
||||
AnimatedNode animatedNode = mNativeAnimatedNodesManager.getNodeById(mInputNode);
|
||||
if (animatedNode != null && animatedNode instanceof ValueAnimatedNode) {
|
||||
mValue = ((ValueAnimatedNode) animatedNode).getValue() % mModulus;
|
||||
final double value = ((ValueAnimatedNode) animatedNode).getValue();
|
||||
mValue = (value % mModulus + mModulus) % mModulus;
|
||||
} else {
|
||||
throw new JSApplicationCausedNativeException("Illegal node ID set as an input for " +
|
||||
"Animated.modulus node");
|
||||
|
||||
Reference in New Issue
Block a user