1
- import type {
1
+ import {
2
2
AnimationConfigWithData ,
3
3
AnimationDirection ,
4
+ AnimationEventCallback ,
4
5
AnimationEventName ,
6
+ AnimationEvents ,
5
7
AnimationItem ,
6
8
AnimationSegment ,
7
9
RendererType ,
8
10
} 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" ;
15
12
16
13
export type LottieRefCurrentProps = {
17
14
play : ( ) => void ;
@@ -41,16 +38,36 @@ export type LottieOptions<T extends RendererType = "svg"> = Omit<
41
38
> & {
42
39
animationData : unknown ;
43
40
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 ;
54
71
} & Omit < React . HTMLProps < HTMLDivElement > , "loop" > ;
55
72
56
73
export type PartialLottieOptions = Omit < LottieOptions , "animationData" > & {
@@ -63,6 +80,7 @@ export type Position = { [key in Axis]: number | [number, number] };
63
80
64
81
export type Action = {
65
82
type : "seek" | "play" | "stop" | "loop" ;
83
+
66
84
frames : [ number ] | [ number , number ] ;
67
85
visibility ?: [ number , number ] ;
68
86
position ?: Position ;
@@ -87,7 +105,7 @@ export type PartialLottieComponentProps = Omit<
87
105
88
106
export type Listener = {
89
107
name : AnimationEventName ;
90
- handler : AnimationEventHandler ;
108
+ handler : AnimationEventCallback < AnimationEvents [ AnimationEventName ] > ;
91
109
} ;
92
110
export type PartialListener = Omit < Listener , "handler" > & {
93
111
handler ?: Listener [ "handler" ] | null ;
0 commit comments