@@ -27,60 +27,78 @@ var Uno;
27
27
}
28
28
static stop ( elementId ) {
29
29
Lottie . withPlayer ( p => {
30
- const a = Lottie . _runningAnimations [ elementId ] . animation ;
31
- a . stop ( ) ;
32
- Lottie . raiseState ( a ) ;
30
+ const currentAnimation = Lottie . _runningAnimations [ elementId ] ;
31
+ if ( currentAnimation ) {
32
+ const a = currentAnimation . animation ;
33
+ a . stop ( ) ;
34
+ Lottie . raiseState ( a ) ;
35
+ }
33
36
} ) ;
34
37
return "ok" ;
35
38
}
36
39
static play ( elementId , fromProgress , toProgress , looped ) {
37
40
Lottie . withPlayer ( p => {
38
- const a = Lottie . _runningAnimations [ elementId ] . animation ;
39
- a . loop = looped ;
40
- const fromFrame = fromProgress * Lottie . _numberOfFrames ;
41
- const toFrame = toProgress * Lottie . _numberOfFrames ;
42
- //Set forceFlag to true in order to force animation to start right away
43
- //Ensures calling play multiple times in quick succession plays the animation properly
44
- a . playSegments ( [ fromFrame , toFrame ] , true ) ;
45
- Lottie . raiseState ( a ) ;
41
+ const currentAnimation = Lottie . _runningAnimations [ elementId ] ;
42
+ if ( currentAnimation ) {
43
+ const a = currentAnimation . animation ;
44
+ a . loop = looped ;
45
+ const fromFrame = fromProgress * Lottie . _numberOfFrames ;
46
+ const toFrame = toProgress * Lottie . _numberOfFrames ;
47
+ //Set forceFlag to true in order to force animation to start right away
48
+ //Ensures calling play multiple times in quick succession plays the animation properly
49
+ a . playSegments ( [ fromFrame , toFrame ] , true ) ;
50
+ Lottie . raiseState ( a ) ;
51
+ }
46
52
} ) ;
47
53
return "ok" ;
48
54
}
49
55
static kill ( elementId ) {
50
56
Lottie . withPlayer ( p => {
51
- Lottie . _runningAnimations [ elementId ] . animation . destroy ( ) ;
52
- delete Lottie . _runningAnimations [ elementId ] ;
57
+ const currentAnimation = Lottie . _runningAnimations [ elementId ] ;
58
+ if ( currentAnimation ) {
59
+ currentAnimation . animation . destroy ( ) ;
60
+ delete Lottie . _runningAnimations [ elementId ] ;
61
+ }
53
62
} ) ;
54
63
return "ok" ;
55
64
}
56
65
static pause ( elementId ) {
57
66
Lottie . withPlayer ( p => {
58
- const a = Lottie . _runningAnimations [ elementId ] . animation ;
59
- a . pause ( ) ;
60
- Lottie . raiseState ( a ) ;
67
+ const currentAnimation = Lottie . _runningAnimations [ elementId ] ;
68
+ if ( currentAnimation ) {
69
+ const a = currentAnimation . animation ;
70
+ a . pause ( ) ;
71
+ Lottie . raiseState ( a ) ;
72
+ }
61
73
} ) ;
62
74
return "ok" ;
63
75
}
64
76
static resume ( elementId ) {
65
77
Lottie . withPlayer ( p => {
66
- const a = Lottie . _runningAnimations [ elementId ] . animation ;
67
- a . play ( ) ;
68
- Lottie . raiseState ( a ) ;
78
+ const currentAnimation = Lottie . _runningAnimations [ elementId ] ;
79
+ if ( currentAnimation ) {
80
+ const a = currentAnimation . animation ;
81
+ a . play ( ) ;
82
+ Lottie . raiseState ( a ) ;
83
+ }
69
84
} ) ;
70
85
return "ok" ;
71
86
}
72
87
static setProgress ( elementId , progress ) {
73
88
Lottie . withPlayer ( p => {
74
- const animation = Lottie . _runningAnimations [ elementId ] . animation ;
75
- let frame = Lottie . _numberOfFrames * progress ;
76
- if ( frame < animation . firstFrame ) {
77
- frame = frame - animation . firstFrame ;
78
- }
79
- else {
80
- frame = animation . getDuration ( true ) * progress ;
89
+ const currentAnimation = Lottie . _runningAnimations [ elementId ] ;
90
+ if ( currentAnimation ) {
91
+ const animation = currentAnimation . animation ;
92
+ let frame = Lottie . _numberOfFrames * progress ;
93
+ if ( frame < animation . firstFrame ) {
94
+ frame = frame - animation . firstFrame ;
95
+ }
96
+ else {
97
+ frame = animation . getDuration ( true ) * progress ;
98
+ }
99
+ animation . goToAndStop ( frame , true ) ;
100
+ Lottie . raiseState ( animation ) ;
81
101
}
82
- animation . goToAndStop ( frame , true ) ;
83
- Lottie . raiseState ( animation ) ;
84
102
} ) ;
85
103
return "ok" ;
86
104
}
@@ -182,7 +200,7 @@ var Uno;
182
200
loop : true ,
183
201
autoplay : properties . autoplay ,
184
202
name : `Lottie-${ properties . elementId } ` ,
185
- renderer : "svg" ,
203
+ renderer : "svg" , // https://github.com/airbnb/lottie-web/wiki/Features
186
204
container : containerElement ,
187
205
rendererSettings : {
188
206
// https://github.com/airbnb/lottie-web/wiki/Renderer-Settings
0 commit comments