Summary:
This diff adds ModuloAnimatedNode on iOS. It separates out code originally submitted in #9048.

Test plan (required)

Set up an animation with a modulo node, and `useNativeModule: true`. Compare results with `useNativeModule: false`.
Closes https://github.com/facebook/react-native/pull/9626

Differential Revision: D3799636

fbshipit-source-id: 594499f11be41bf3ee709249056a3feedeace9eb
This commit is contained in:
Ryan Gomba 2016-08-31 14:38:53 -07:00 коммит произвёл Facebook Github Bot 3
Родитель 7db93a376b
Коммит 82dba51f1a
5 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -1176,6 +1176,11 @@ class AnimatedModulo extends AnimatedWithChildren {
this._modulus = modulus;
}
__makeNative() {
super.__makeNative();
this._a.__makeNative();
}
__getValue(): number {
return (this._a.__getValue() % this._modulus + this._modulus) % this._modulus;
}
@ -1191,6 +1196,14 @@ class AnimatedModulo extends AnimatedWithChildren {
__detach(): void {
this._a.__removeChild(this);
}
__getNativeConfig(): any {
return {
type: 'modulus',
input: this._a.__getNativeTag(),
modulus: this._modulus,
};
}
}
class AnimatedDiffClamp extends AnimatedWithChildren {

Просмотреть файл

@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTValueAnimatedNode.h"
@interface RCTModuloAnimatedNode : RCTValueAnimatedNode
@end

Просмотреть файл

@ -0,0 +1,23 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTModuloAnimatedNode.h"
@implementation RCTModuloAnimatedNode
- (void)performUpdate
{
[super performUpdate];
NSNumber *inputNode = self.config[@"input"];
NSNumber *modulus = self.config[@"modulus"];
RCTValueAnimatedNode *parent = (RCTValueAnimatedNode *)self.parentNodes[inputNode];
self.value = fmodf(parent.value, modulus.floatValue);
}
@end

Просмотреть файл

@ -19,6 +19,7 @@
13E501EE1D07A6C9005F35D8 /* RCTStyleAnimatedNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E501E31D07A6C9005F35D8 /* RCTStyleAnimatedNode.m */; };
13E501EF1D07A6C9005F35D8 /* RCTTransformAnimatedNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E501E51D07A6C9005F35D8 /* RCTTransformAnimatedNode.m */; };
13E501F01D07A6C9005F35D8 /* RCTValueAnimatedNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E501E71D07A6C9005F35D8 /* RCTValueAnimatedNode.m */; };
94DAE3F91D7334A70059942F /* RCTModuloAnimatedNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 94DAE3F81D7334A70059942F /* RCTModuloAnimatedNode.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -59,6 +60,8 @@
13E501E51D07A6C9005F35D8 /* RCTTransformAnimatedNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTransformAnimatedNode.m; sourceTree = "<group>"; };
13E501E61D07A6C9005F35D8 /* RCTValueAnimatedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTValueAnimatedNode.h; sourceTree = "<group>"; };
13E501E71D07A6C9005F35D8 /* RCTValueAnimatedNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTValueAnimatedNode.m; sourceTree = "<group>"; };
94DAE3F71D7334A70059942F /* RCTModuloAnimatedNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTModuloAnimatedNode.h; sourceTree = "<group>"; };
94DAE3F81D7334A70059942F /* RCTModuloAnimatedNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTModuloAnimatedNode.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -91,6 +94,8 @@
13E501DB1D07A6C9005F35D8 /* RCTAnimationDriverNode.m */,
13E501DC1D07A6C9005F35D8 /* RCTInterpolationAnimatedNode.h */,
13E501DD1D07A6C9005F35D8 /* RCTInterpolationAnimatedNode.m */,
94DAE3F71D7334A70059942F /* RCTModuloAnimatedNode.h */,
94DAE3F81D7334A70059942F /* RCTModuloAnimatedNode.m */,
13E501DE1D07A6C9005F35D8 /* RCTMultiplicationAnimatedNode.h */,
13E501DF1D07A6C9005F35D8 /* RCTMultiplicationAnimatedNode.m */,
13E501E01D07A6C9005F35D8 /* RCTPropsAnimatedNode.h */,
@ -176,6 +181,7 @@
buildActionMask = 2147483647;
files = (
13E501F01D07A6C9005F35D8 /* RCTValueAnimatedNode.m in Sources */,
94DAE3F91D7334A70059942F /* RCTModuloAnimatedNode.m in Sources */,
13E501EE1D07A6C9005F35D8 /* RCTStyleAnimatedNode.m in Sources */,
13E501CC1D07A644005F35D8 /* RCTAnimationUtils.m in Sources */,
13E501CF1D07A644005F35D8 /* RCTNativeAnimatedModule.m in Sources */,

Просмотреть файл

@ -15,6 +15,7 @@
#import "RCTConvert.h"
#import "RCTInterpolationAnimatedNode.h"
#import "RCTLog.h"
#import "RCTModuloAnimatedNode.h"
#import "RCTMultiplicationAnimatedNode.h"
#import "RCTPropsAnimatedNode.h"
#import "RCTStyleAnimatedNode.h"
@ -69,6 +70,7 @@ RCT_EXPORT_METHOD(createAnimatedNode:(nonnull NSNumber *)tag
@"interpolation" : [RCTInterpolationAnimatedNode class],
@"addition" : [RCTAdditionAnimatedNode class],
@"multiplication" : [RCTMultiplicationAnimatedNode class],
@"modulus" : [RCTModuloAnimatedNode class],
@"transform" : [RCTTransformAnimatedNode class]};
});