mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
4a227ce2ab
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32736 The ability to pass an additional property bag to further configure NativeAnimated is useful for a few reasons, e.g., experimentation with multiple implementations of the NativeAnimated module. The specific use case this solves is on react-native-windows, where there are two underlying animation graph options, one "optimized" animation graph that uses UI.Composition, and another similar to the approach to iOS and Android that uses a frame rendering callback. The platform configuration can be supplied to the animation node when `useNativeDriver` is set to `true`, and we pass the platform configuration object to the connected AnimatedValue and all it's children. Changelog: [General][Added] - Option to supply `platformConfig` to NativeAnimated Reviewed By: yungsters Differential Revision: D32988285 fbshipit-source-id: ab8a7bbf197573fc9e9a4737c255f124321295ac
65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const AnimatedInterpolation = require('./AnimatedInterpolation');
|
|
const AnimatedNode = require('./AnimatedNode');
|
|
const AnimatedValue = require('./AnimatedValue');
|
|
const AnimatedWithChildren = require('./AnimatedWithChildren');
|
|
|
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
import type {InterpolationConfigType} from './AnimatedInterpolation';
|
|
|
|
class AnimatedAddition extends AnimatedWithChildren {
|
|
_a: AnimatedNode;
|
|
_b: AnimatedNode;
|
|
|
|
constructor(a: AnimatedNode | number, b: AnimatedNode | number) {
|
|
super();
|
|
this._a = typeof a === 'number' ? new AnimatedValue(a) : a;
|
|
this._b = typeof b === 'number' ? new AnimatedValue(b) : b;
|
|
}
|
|
|
|
__makeNative(platformConfig: ?PlatformConfig) {
|
|
this._a.__makeNative(platformConfig);
|
|
this._b.__makeNative(platformConfig);
|
|
super.__makeNative(platformConfig);
|
|
}
|
|
|
|
__getValue(): number {
|
|
return this._a.__getValue() + this._b.__getValue();
|
|
}
|
|
|
|
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
|
|
return new AnimatedInterpolation(this, config);
|
|
}
|
|
|
|
__attach(): void {
|
|
this._a.__addChild(this);
|
|
this._b.__addChild(this);
|
|
}
|
|
|
|
__detach(): void {
|
|
this._a.__removeChild(this);
|
|
this._b.__removeChild(this);
|
|
super.__detach();
|
|
}
|
|
|
|
__getNativeConfig(): any {
|
|
return {
|
|
type: 'addition',
|
|
input: [this._a.__getNativeTag(), this._b.__getNativeTag()],
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = AnimatedAddition;
|