Merge pull request #28732 from iyegoroff/react-native

react-native: fixed Animated.EventConfig
This commit is contained in:
Eloy Durán
2018-09-10 15:32:51 +02:00
committed by GitHub
2 changed files with 16 additions and 5 deletions
+3 -3
View File
@@ -8465,8 +8465,8 @@ export namespace Animated {
export function parallel(animations: Array<CompositeAnimation>, config?: ParallelConfig): CompositeAnimation;
type Mapping = { [key: string]: Mapping } | AnimatedValue;
interface EventConfig {
listener?: ValueListenerCallback;
interface EventConfig<T> {
listener?: (event?: NativeSyntheticEvent<T>) => void;
useNativeDriver?: boolean;
}
@@ -8486,7 +8486,7 @@ export namespace Animated {
* ]),
*```
*/
export function event(argMapping: Array<Mapping | null>, config?: EventConfig): (...args: any[]) => void;
export function event<T>(argMapping: Array<Mapping | null>, config?: EventConfig<T>): (...args: any[]) => void;
/**
* Make any React component Animatable. Used to create `Animated.View`, etc.
+13 -2
View File
@@ -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
@@ -63,6 +63,17 @@ function TestAnimatedAPI() {
Animated.stagger(100, [spring1, springXY]);
const listener = (e?: NativeSyntheticEvent<NativeScrollEvent>) => {
if (e) {
console.warn(e.nativeEvent.contentOffset.y);
}
};
Animated.event(
[{ nativeEvent: { contentOffset: { y: v1 } } }],
{ useNativeDriver: true, listener },
);
return (
<View>
<Animated.View