From 26e8870fbf310f0fb438a86cb2fe260f0bc419b9 Mon Sep 17 00:00:00 2001 From: Poyan Nabati Date: Mon, 6 Jan 2020 21:28:03 -0800 Subject: [PATCH] Add AnimatedInterpolation as possible type for toValue (#27558) Summary: AnimatedInterpolation should be a valid type to pass to `toValue` according to the documentation. https://facebook.github.io/react-native/docs/animations#tracking-dynamic-values ## Changelog [General] [Fixed] - Add AnimationInterpolation as possible type for toValue Pull Request resolved: https://github.com/facebook/react-native/pull/27558 Test Plan: `yarn flow` works without errors. Differential Revision: D19296804 Pulled By: cpojer fbshipit-source-id: 7f09c762308c40f1eede5834fadf1837114aa397 --- Libraries/Animated/src/animations/SpringAnimation.js | 6 ++++-- Libraries/Animated/src/animations/TimingAnimation.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Libraries/Animated/src/animations/SpringAnimation.js b/Libraries/Animated/src/animations/SpringAnimation.js index 61ff7cfa7cc..f9957d38fcf 100644 --- a/Libraries/Animated/src/animations/SpringAnimation.js +++ b/Libraries/Animated/src/animations/SpringAnimation.js @@ -12,6 +12,7 @@ const AnimatedValue = require('../nodes/AnimatedValue'); const AnimatedValueXY = require('../nodes/AnimatedValueXY'); +const AnimatedInterpolation = require('../nodes/AnimatedInterpolation'); const Animation = require('./Animation'); const SpringConfig = require('../SpringConfig'); @@ -30,7 +31,8 @@ export type SpringAnimationConfig = AnimationConfig & { y: number, ... } - | AnimatedValueXY, + | AnimatedValueXY + | AnimatedInterpolation, overshootClamping?: boolean, restDisplacementThreshold?: number, restSpeedThreshold?: number, @@ -53,7 +55,7 @@ export type SpringAnimationConfig = AnimationConfig & { }; export type SpringAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, + toValue: number | AnimatedValue | AnimatedInterpolation, overshootClamping?: boolean, restDisplacementThreshold?: number, restSpeedThreshold?: number, diff --git a/Libraries/Animated/src/animations/TimingAnimation.js b/Libraries/Animated/src/animations/TimingAnimation.js index f88f7207e60..33ab52b3961 100644 --- a/Libraries/Animated/src/animations/TimingAnimation.js +++ b/Libraries/Animated/src/animations/TimingAnimation.js @@ -12,6 +12,7 @@ const AnimatedValue = require('../nodes/AnimatedValue'); const AnimatedValueXY = require('../nodes/AnimatedValueXY'); +const AnimatedInterpolation = require('../nodes/AnimatedInterpolation'); const Animation = require('./Animation'); const {shouldUseNativeDriver} = require('../NativeAnimatedHelper'); @@ -27,7 +28,8 @@ export type TimingAnimationConfig = AnimationConfig & { y: number, ... } - | AnimatedValueXY, + | AnimatedValueXY + | AnimatedInterpolation, easing?: (value: number) => number, duration?: number, delay?: number, @@ -35,7 +37,7 @@ export type TimingAnimationConfig = AnimationConfig & { }; export type TimingAnimationConfigSingle = AnimationConfig & { - toValue: number | AnimatedValue, + toValue: number | AnimatedValue | AnimatedInterpolation, easing?: (value: number) => number, duration?: number, delay?: number,