Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 types #840

Merged
merged 44 commits into from
Jul 22, 2020
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a6ebc56
create type definition for useSharedValue
renanmav May 29, 2020
f0232a7
add value prop to AnimatedValue class and correctly export useSharedV…
renanmav May 29, 2020
13027f3
create typings for useAnimatedStyle
renanmav May 29, 2020
1239b53
add type definitions for useDerivedValue
renanmav May 29, 2020
404116e
add type definitions to useAnimatedGestureHandler
renanmav May 29, 2020
6becb07
add type definitions to useAnimatedScrollHandler
renanmav May 30, 2020
ac7222f
add type definitions to withTiming animation
renanmav May 30, 2020
0a135c3
add type definitions to withSpring animation
renanmav May 30, 2020
869bd35
add type definitions to cancelAnimation animation
renanmav May 30, 2020
dff0c13
add type definitions to delay animation
renanmav May 30, 2020
ba1ced6
add type definitions to loop animation
renanmav May 30, 2020
726d207
create SharedValue and interpolation function
renanmav Jun 3, 2020
69cfd6c
update cancelAnimation to use SharedValue
renanmav Jun 3, 2020
c20cb07
remove SharedValue extension
renanmav Jun 4, 2020
8d785b1
move SharedValue from class to interface
renanmav Jun 4, 2020
40fc26a
update new SharedValueType within reanimated 2 hooks
renanmav Jun 4, 2020
7543620
fix typo
renanmav Jun 4, 2020
37f3d38
Add runOnUI()
wcandillon Jun 9, 2020
404ade8
Update react-native-reanimated.d.ts
wcandillon Jun 11, 2020
8a9f00b
Update react-native-reanimated.d.ts
wcandillon Jun 11, 2020
fffcb9f
Merge pull request #1 from wcandillon/patch-27
renanmav Jun 11, 2020
a52c71d
add extends to first generic of runOnUI
renanmav Jun 12, 2020
b415532
use SharedValue instead of Value for cancelAnimation
renanmav Jun 12, 2020
6cf634e
update useSharedValue definition and remove Function from RawSharedValue
renanmav Jun 15, 2020
173312d
merge with master
renanmav Jun 15, 2020
983e0f8
export SharedValue type definition
renanmav Jun 15, 2020
919c762
remove function implementation from useSharedValue definition
renanmav Jun 15, 2020
b4123c3
add generic to SharedValue within cancelAnimation definition
renanmav Jun 15, 2020
10179a0
typecheck: add tsc to type check typings
renanmav Jun 23, 2020
464fb3d
typecheck: add tests for reanimated 2 hooks
renanmav Jun 23, 2020
e71cb95
typecheck: add tests for reanimated 2 animations
renanmav Jun 23, 2020
9015559
Merge branch 'master' of github.com:software-mansion/react-native-rea…
renanmav Jun 24, 2020
9ea6457
Update react-native-reanimated.d.ts
wcandillon Jul 2, 2020
daef5ff
Update react-native-reanimated.d.ts
wcandillon Jul 2, 2020
e531ad3
Merge pull request #2 from wcandillon/patch-30
renanmav Jul 2, 2020
774e99b
Merge branch 'master' of github.com:software-mansion/react-native-rea…
renanmav Jul 3, 2020
7dd60e8
Merge branch 'master' of github.com:software-mansion/react-native-rea…
renanmav Jul 11, 2020
0f0f96a
add typings for withDecay
renanmav Jul 11, 2020
5fd666e
add velocity to WithSpringConfig
renanmav Jul 11, 2020
1194b6a
make velocity not required
renanmav Jul 14, 2020
ff00926
Merge branch 'master' into v2-types
wcandillon Jul 18, 2020
b2d9bb0
Merge pull request #3 from wcandillon/v2-types
renanmav Jul 20, 2020
ea823e1
1. Remove loop function
likern Jul 20, 2020
4068431
Merge pull request #4 from likern/v2-types
renanmav Jul 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 23 additions & 9 deletions react-native-reanimated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ declare module 'react-native-reanimated' {
TextStyle,
ImageStyle,
TransformsStyle,
FlexStyle,
View as ReactNativeView,
Text as ReactNativeText,
Image as ReactNativeImage,
Expand Down Expand Up @@ -64,13 +63,17 @@ declare module 'react-native-reanimated' {
class AnimatedValue<T extends Value> extends AnimatedNode<T> {
constructor(value?: T);

value: T;

setValue(value: Adaptable<T>): void;

interpolate(config: InterpolationConfig): AnimatedNode<number>;
}

class SharedValue<T extends Value> extends AnimatedNode<T> {
renanmav marked this conversation as resolved.
Show resolved Hide resolved
constructor(value?: T);

value: T;
}

export type Mapping = { [key: string]: Mapping } | Adaptable<any>;
export type Adaptable<T> =
| T
Expand Down Expand Up @@ -351,6 +354,14 @@ declare module 'react-native-reanimated' {
export const max: BinaryOperator;
export const min: BinaryOperator;

// reanimated2 derived operations
export function interpolate(
x: number,
input: Array<number>,
output: Array<number>,
type: Extrapolate
): number;

// animations
export function decay(
clock: AnimatedClock,
Expand Down Expand Up @@ -416,14 +427,14 @@ declare module 'react-native-reanimated' {
// reanimated2 hooks
export function useSharedValue<T extends Value>(
renanmav marked this conversation as resolved.
Show resolved Hide resolved
initialValue: T
): AnimatedValue<T>;
): SharedValue<T>;
export function useDerivedValue<T extends Value>(
processor: () => T
): AnimatedValue<T>;
export function useAnimatedStyle<T extends FlexStyle, TransformsStyle = ViewStyle>(
): SharedValue<T>;
export function useAnimatedStyle<T extends ViewStyle, TextStyle, ImageStyle>(
renanmav marked this conversation as resolved.
Show resolved Hide resolved
updater: () => T
): T;
export function useAnimatedGestureHandler<TContext extends object>(
export function useAnimatedGestureHandler<TContext extends Context>(
handlers: GestureHandlers<TContext>
): OnGestureEvent;
export function useAnimatedScrollHandler(
Expand All @@ -439,10 +450,12 @@ declare module 'react-native-reanimated' {
// gesture-handler
type OnGestureEvent = (event: PanGestureHandlerGestureEvent) => void;

type Context = { [key: string]: any };

type NativeEvent = GestureHandlerGestureEventNativeEvent & PanGestureHandlerEventExtra;
type Handler<TContext extends object> = (event: NativeEvent, context: TContext) => void;
type Handler<TContext extends Context> = (event: NativeEvent, context: TContext) => void;

export interface GestureHandlers<TContext extends object> {
export interface GestureHandlers<TContext extends Context> {
onStart?: Handler<TContext>;
onActive?: Handler<TContext>;
onEnd?: Handler<TContext>;
Expand Down Expand Up @@ -591,4 +604,5 @@ declare module 'react-native-reanimated' {
export const cancelAnimation: typeof Animated.cancelAnimation
export const delay: typeof Animated.delay
export const loop: typeof Animated.loop
export const interpolate: typeof Animated.interpolate
}