Fix initial value of native Animated.Value

Summary:
Native Animated.Value uses the value it was created with when sending the config to native but this causes issue when the value has changed before calling `__makeNative` this happens with the `progress` value for `NavigationExperimental`. It gets initialized with value 1, then uses `setValue` to change it to 0 before starting the animation and this is when `__makeNative` is called. This simply uses the current value instead of the value passed to the constructor. Also pass offset so native implementations that support it can use it (iOS).

**Test plan**
Tested that the first transition that uses the `progress` animated value is not broken in an app that uses `NavigationExperimental` when using `useNativeDriver` for animations.
Closes https://github.com/facebook/react-native/pull/10656

Differential Revision: D4107624

fbshipit-source-id: 921cf4a3422cf91923bc315fd7a15c508becddae
This commit is contained in:
Janic Duplessis 2016-10-31 20:39:44 -07:00 committed by Facebook Github Bot
parent c089761f9b
commit 2b49eddcfd
1 changed files with 3 additions and 3 deletions

View File

@ -671,7 +671,6 @@ var _uniqueId = 1;
*/ */
class AnimatedValue extends AnimatedWithChildren { class AnimatedValue extends AnimatedWithChildren {
_value: number; _value: number;
_startingValue: number;
_offset: number; _offset: number;
_animation: ?Animation; _animation: ?Animation;
_tracking: ?Animated; _tracking: ?Animated;
@ -680,7 +679,7 @@ class AnimatedValue extends AnimatedWithChildren {
constructor(value: number) { constructor(value: number) {
super(); super();
this._startingValue = this._value = value; this._value = value;
this._offset = 0; this._offset = 0;
this._animation = null; this._animation = null;
this._listeners = {}; this._listeners = {};
@ -879,7 +878,8 @@ class AnimatedValue extends AnimatedWithChildren {
__getNativeConfig(): Object { __getNativeConfig(): Object {
return { return {
type: 'value', type: 'value',
value: this._startingValue, value: this._value,
offset: this._offset,
}; };
} }
} }