From f72507f3c55873f8d93a1627ab7edef3b075c891 Mon Sep 17 00:00:00 2001 From: iyegoroff Date: Sat, 8 Sep 2018 18:02:19 +0300 Subject: [PATCH 1/3] fixed Animated.EventConfig --- types/react-native/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index f66e46cb1e..ad8abe57fd 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -8465,8 +8465,8 @@ export namespace Animated { export function parallel(animations: Array, config?: ParallelConfig): CompositeAnimation; type Mapping = { [key: string]: Mapping } | AnimatedValue; - interface EventConfig { - listener?: ValueListenerCallback; + interface EventConfig { + listener?: (event?: NativeSyntheticEvent) => void; useNativeDriver?: boolean; } @@ -8486,7 +8486,7 @@ export namespace Animated { * ]), *``` */ - export function event(argMapping: Array, config?: EventConfig): (...args: any[]) => void; + export function event(argMapping: Array, config?: EventConfig): (...args: any[]) => void; /** * Make any React component Animatable. Used to create `Animated.View`, etc. From 4e5b1485d63fc672db755db7df5a6b6fca12a493 Mon Sep 17 00:00:00 2001 From: iyegoroff Date: Sat, 8 Sep 2018 18:24:12 +0300 Subject: [PATCH 2/3] added Animated.event test --- types/react-native/test/animated.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index c27af04bb9..dab64d9d78 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -1,6 +1,6 @@ -import * as React from "react-native"; +import * as React from "react"; -import { Animated, View } from "react-native"; +import { Animated, View, NativeSyntheticEvent, NativeScrollEvent } from "react-native"; function TestAnimatedAPI() { // Value @@ -62,6 +62,17 @@ function TestAnimatedAPI() { Animated.sequence([spring1, springXY]); Animated.stagger(100, [spring1, springXY]); + + const listener = (e?: NativeSyntheticEvent) => { + if (e) { + console.warn(e.nativeEvent.contentOffset.y); + } + }; + + Animated.event( + [{ nativeEvent: { contentOffset: { y: v1 } } }], + { useNativeDriver: true, listener }, + ); return ( From 7f0cd433de22a10d890c2e02a6a8cf23f7397617 Mon Sep 17 00:00:00 2001 From: iyegoroff Date: Sat, 8 Sep 2018 18:30:18 +0300 Subject: [PATCH 3/3] Update animated.tsx --- types/react-native/test/animated.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index dab64d9d78..40f8c37ee7 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -62,7 +62,7 @@ function TestAnimatedAPI() { Animated.sequence([spring1, springXY]); Animated.stagger(100, [spring1, springXY]); - + const listener = (e?: NativeSyntheticEvent) => { if (e) { console.warn(e.nativeEvent.contentOffset.y);