From c4625f73f5ae1f2ebf0c8564d65555c369bbe6f3 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Wed, 8 May 2019 14:59:24 +0200 Subject: [PATCH 1/2] =?UTF-8?q?fix(=F0=9F=93=A6):=20Make=20runSpring=20con?= =?UTF-8?q?figurable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AnimationRunners.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/AnimationRunners.ts b/src/AnimationRunners.ts index 8db54d9f..5cdfc553 100644 --- a/src/AnimationRunners.ts +++ b/src/AnimationRunners.ts @@ -1,4 +1,4 @@ -import Animated from "react-native-reanimated"; +import Animated, {SpringConfig} from "react-native-reanimated"; const { Clock, @@ -60,15 +60,7 @@ export function runSpring( clock: Clock, value: Adaptable, dest: Adaptable, -) { - const state = { - finished: new Value(0), - velocity: new Value(0), - position: new Value(0), - time: new Value(0), - }; - - const config = { + config: SpringConfig = { toValue: new Value(0), damping: 7, mass: 1, @@ -76,6 +68,13 @@ export function runSpring( overshootClamping: false, restSpeedThreshold: 0.001, restDisplacementThreshold: 0.001, + } +) { + const state = { + finished: new Value(0), + velocity: new Value(0), + position: new Value(0), + time: new Value(0), }; return block([ From 97422be93082f49f09c23723ee59ce60a26c2137 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Wed, 8 May 2019 15:05:47 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=92=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AnimationRunners.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AnimationRunners.ts b/src/AnimationRunners.ts index 5cdfc553..4893596c 100644 --- a/src/AnimationRunners.ts +++ b/src/AnimationRunners.ts @@ -1,4 +1,4 @@ -import Animated, {SpringConfig} from "react-native-reanimated"; +import Animated from "react-native-reanimated"; const { Clock, @@ -15,8 +15,11 @@ const { add, } = Animated; -export { timing, clockRunning, add }; +export { + timing, spring, clockRunning, add, +}; +export type SpringConfig= Parameters[1]; export type TimingConfig = Parameters[1]; export type Clock = Parameters[0]; export type Node = ReturnType; @@ -68,7 +71,7 @@ export function runSpring( overshootClamping: false, restSpeedThreshold: 0.001, restDisplacementThreshold: 0.001, - } + }, ) { const state = { finished: new Value(0), @@ -83,7 +86,7 @@ export function runSpring( set(state.time, 0), set(state.position, value), set(state.velocity, 0), - set(config.toValue, dest), + set(config.toValue as any, dest), startClock(clock), ]), spring(clock, state, config),