Skip to content

Commit dac55b8

Browse files
committed
chore: update types
1 parent bd794d2 commit dac55b8

File tree

1 file changed

+36
-18
lines changed

1 file changed

+36
-18
lines changed

src/types.ts

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import type {
1+
import {
22
AnimationConfigWithData,
33
AnimationDirection,
4+
AnimationEventCallback,
45
AnimationEventName,
6+
AnimationEvents,
57
AnimationItem,
68
AnimationSegment,
79
RendererType,
810
} from "lottie-web";
9-
import React, {
10-
MutableRefObject,
11-
AnimationEventHandler,
12-
ReactElement,
13-
RefObject,
14-
} from "react";
11+
import React, { MutableRefObject, ReactElement, RefObject } from "react";
1512

1613
export type LottieRefCurrentProps = {
1714
play: () => void;
@@ -41,16 +38,36 @@ export type LottieOptions<T extends RendererType = "svg"> = Omit<
4138
> & {
4239
animationData: unknown;
4340
lottieRef?: LottieRef;
44-
onComplete?: AnimationEventHandler | null;
45-
onLoopComplete?: AnimationEventHandler | null;
46-
onEnterFrame?: AnimationEventHandler | null;
47-
onSegmentStart?: AnimationEventHandler | null;
48-
onConfigReady?: AnimationEventHandler | null;
49-
onDataReady?: AnimationEventHandler | null;
50-
onDataFailed?: AnimationEventHandler | null;
51-
onLoadedImages?: AnimationEventHandler | null;
52-
onDOMLoaded?: AnimationEventHandler | null;
53-
onDestroy?: AnimationEventHandler | null;
41+
onComplete?: AnimationEventCallback<
42+
AnimationEvents[AnimationEventName]
43+
> | null;
44+
onLoopComplete?: AnimationEventCallback<
45+
AnimationEvents[AnimationEventName]
46+
> | null;
47+
onEnterFrame?: AnimationEventCallback<
48+
AnimationEvents[AnimationEventName]
49+
> | null;
50+
onSegmentStart?: AnimationEventCallback<
51+
AnimationEvents[AnimationEventName]
52+
> | null;
53+
onConfigReady?: AnimationEventCallback<
54+
AnimationEvents[AnimationEventName]
55+
> | null;
56+
onDataReady?: AnimationEventCallback<
57+
AnimationEvents[AnimationEventName]
58+
> | null;
59+
onDataFailed?: AnimationEventCallback<
60+
AnimationEvents[AnimationEventName]
61+
> | null;
62+
onLoadedImages?: AnimationEventCallback<
63+
AnimationEvents[AnimationEventName]
64+
> | null;
65+
onDOMLoaded?: AnimationEventCallback<
66+
AnimationEvents[AnimationEventName]
67+
> | null;
68+
onDestroy?: AnimationEventCallback<
69+
AnimationEvents[AnimationEventName]
70+
> | null;
5471
} & Omit<React.HTMLProps<HTMLDivElement>, "loop">;
5572

5673
export type PartialLottieOptions = Omit<LottieOptions, "animationData"> & {
@@ -63,6 +80,7 @@ export type Position = { [key in Axis]: number | [number, number] };
6380

6481
export type Action = {
6582
type: "seek" | "play" | "stop" | "loop";
83+
6684
frames: [number] | [number, number];
6785
visibility?: [number, number];
6886
position?: Position;
@@ -87,7 +105,7 @@ export type PartialLottieComponentProps = Omit<
87105

88106
export type Listener = {
89107
name: AnimationEventName;
90-
handler: AnimationEventHandler;
108+
handler: AnimationEventCallback<AnimationEvents[AnimationEventName]>;
91109
};
92110
export type PartialListener = Omit<Listener, "handler"> & {
93111
handler?: Listener["handler"] | null;

0 commit comments

Comments
 (0)