1
- import * as React from 'react' ;
1
+ declare module "lottie-react-native" {
2
+ import { Animated , StyleProp , ViewStyle } from "react-native" ;
2
3
3
- import {
4
- Animated ,
5
- StyleProp ,
6
- ViewProperties ,
7
- ViewStyle
8
- } from 'react-native' ;
9
-
10
- export interface AnimationObject {
11
- v : string ;
12
- fr : number ;
13
- ip : number ;
14
- op : number ;
15
- w : number ;
16
- h : number ;
17
- nm : string ;
18
- ddd : number ;
19
- assets : any [ ] ;
20
- layers : any [ ] ;
21
- }
22
-
23
- export interface AnimationProps extends ViewProperties {
24
4
/**
25
- * The source of animation. Can be referenced as a local asset by a string, or remotely
26
- * with an object with a `uri` property, or it can be an actual JS object of an
27
- * animation, obtained (for example) with something like
28
- * `require('../path/to/animation.json')`
5
+ * Serialized animation as generated from After Effects
29
6
*/
30
- source : string | AnimationObject | { uri : string } ;
7
+ interface AnimationObject {
8
+ v : string ;
9
+ fr : number ;
10
+ ip : number ;
11
+ op : number ;
12
+ w : number ;
13
+ h : number ;
14
+ nm : string ;
15
+ ddd : number ;
16
+ assets : any [ ] ;
17
+ layers : any [ ] ;
18
+ }
31
19
32
20
/**
33
- * A number between 0 and 1, or an `Animated` number between 0 and 1. This number
34
- * represents the normalized progress of the animation. If you update this prop, the
35
- * animation will correspondingly update to the frame at that progress value. This
36
- * prop is not required if you are using the imperative API.
21
+ * Properties of the AnimatedLottieView component
37
22
*/
38
- progress ?: number | Animated . Value ;
23
+ interface AnimatedLottieViewProps {
24
+ /**
25
+ * The source of animation. Can be referenced as a local asset by a string, or remotely
26
+ * with an object with a `uri` property, or it can be an actual JS object of an
27
+ * animation, obtained (for example) with something like
28
+ * `require('../path/to/animation.json')`
29
+ */
30
+ source : string | AnimationObject | { uri : string } ;
39
31
40
- /**
41
- * The speed the animation will progress. This only affects the imperative API. The
42
- * default value is 1.
43
- */
44
- speed ?: number ;
32
+ /**
33
+ * A number between 0 and 1, or an `Animated` number between 0 and 1. This number
34
+ * represents the normalized progress of the animation. If you update this prop, the
35
+ * animation will correspondingly update to the frame at that progress value. This
36
+ * prop is not required if you are using the imperative API.
37
+ */
38
+ progress ?: number | Animated . Value ;
45
39
46
- /**
47
- * A boolean flag indicating whether or not the animation should loop.
48
- */
49
- loop ?: boolean ;
40
+ /**
41
+ * The speed the animation will progress. This only affects the imperative API. The
42
+ * default value is 1.
43
+ */
44
+ speed ?: number ;
50
45
51
- /**
52
- * Style attributes for the view, as expected in a standard `View`:
53
- * http://facebook.github.io/react-native/releases/0.39/docs/view.html#style
54
- * CAVEAT: border styling is not supported.
55
- */
56
- style ?: StyleProp < ViewStyle > ;
46
+ /**
47
+ * A boolean flag indicating whether or not the animation should loop.
48
+ */
49
+ loop ?: boolean ;
57
50
58
- /**
59
- * [Android] Relative folder inside of assets containing image files to be animated.
60
- * Make sure that the images that bodymovin export are in that folder with their names unchanged (should be img_#).
61
- * Refer to https://github.com/airbnb/lottie-android#image-support for more details.
62
- * @platform android
63
- */
64
- imageAssetsFolder ?: string ;
51
+ /**
52
+ * Style attributes for the view, as expected in a standard `View`:
53
+ * http://facebook.github.io/react-native/releases/0.39/docs/view.html#style
54
+ * CAVEAT: border styling is not supported.
55
+ */
56
+ style ?: StyleProp < ViewStyle > ;
65
57
66
- /**
67
- * [Android]. Uses hardware acceleration to perform the animation. This should only
68
- * be used for animations where your width and height are equal to the composition width
69
- * and height, e.g. you are not scaling the animation.
70
- * @platform android
71
- */
72
- hardwareAccelerationAndroid ?: boolean ;
73
- }
58
+ /**
59
+ * [Android] Relative folder inside of assets containing image files to be animated.
60
+ * Make sure that the images that bodymovin export are in that folder with their names unchanged (should be img_#).
61
+ * Refer to https://github.com/airbnb/lottie-android#image-support for more details.
62
+ * @platform android
63
+ */
64
+ imageAssetsFolder ?: string ;
74
65
75
- export default class Animation extends React . Component < AnimationProps , { } > {
76
- /**
77
- * Play the animation all the way through, at the speed specified as a prop.
78
- */
79
- play : ( ) => { } ;
66
+ /**
67
+ * [Android]. Uses hardware acceleration to perform the animation. This should only
68
+ * be used for animations where your width and height are equal to the composition width
69
+ * and height, e.g. you are not scaling the animation.
70
+ * @platform android
71
+ */
72
+ hardwareAccelerationAndroid ?: boolean ;
73
+ }
80
74
81
75
/**
82
- * Reset the animation back to `0` progress.
76
+ * View hosting the lottie animation. In order to successfully import this definition in
77
+ * your typescript file, you need to import the view as:
78
+ *
79
+ * `import LottieView = require("lottie-react-native");`
80
+ *
81
+ * Otherwise the compiler will give you issues and won't work.
83
82
*/
84
- reset : ( ) => { }
85
- }
83
+ class AnimatedLottieView extends React . Component < AnimatedLottieViewProps , { } > {
84
+ play ( startFrame ?: number , endFrame ?: number ) : void ;
85
+ reset ( ) : void ;
86
+ }
87
+
88
+ export = AnimatedLottieView ;
89
+ }
0 commit comments