1
1
<template >
2
- <div class =" w-full lf-relative vue-lottie-player" >
2
+ <div class =" lf- w-full lf-relative vue-lottie-player" >
3
3
<div
4
4
v-if =" loading"
5
- class =" w-full lf-h-full lf-absolute lf-flex lf-justify-center lf-items-center"
5
+ class =" lf- w-full lf-h-full lf-absolute lf-flex lf-justify-center lf-items-center"
6
6
>
7
7
<div class =" lf-spinner" ></div >
8
8
</div >
@@ -129,8 +129,6 @@ export default {
129
129
},
130
130
methods: {
131
131
togglePlayPause () {
132
- console .log (" called toggle play pause" );
133
- console .log (this .options .playing );
134
132
if (this .options .playing ) {
135
133
this .player .pause ();
136
134
this .options .playing = false ;
@@ -139,62 +137,15 @@ export default {
139
137
this .options .playing = true ;
140
138
}
141
139
},
142
- mounted () {
143
- this .player = this .$refs .player ;
144
- this .player .addEventListener (' ready' , function () {
145
- this .options .animation = this .player .getLottie ();
146
- this .loading = false ;
147
- }.bind (this ));
148
- this .player .addEventListener (' complete' , function () {
149
- this .stop ();
150
- }.bind (this ));
151
- this .options .backgroundColor = this .backgroundColor ;
152
- this .options .speed = this .speed ;
153
- this .options .loop = this .loop ;
154
- this .options .playing = this .autoplay ;
155
- },
156
- methods: {
157
- togglePlayPause () {
158
- if (this .options .playing ) {
159
- this .player .pause ();
160
- this .options .playing = false ;
161
- } else {
162
- this .player .play ();
163
- this .options .playing = true ;
164
- }
165
- },
166
- toggleLoop () {
167
- if (this .options .loop ) {
168
- this .player .setLooping (false );
169
- this .options .loop = false ;
170
- } else {
171
- this .player .setLooping (true );
172
- this .options .loop = true ;
173
- this .options .playing = true ;
174
- this .player .play ();
175
- }
176
- },
177
- setPlayerSpeed (speed ) {
178
- this .player .setSpeed (speed);
179
- this .$emit (' setPlayerSpeed' , speed);
180
- },
181
- stop () {
182
- this .player .seek (1 );
183
- this .player .stop ();
184
- this .options .playing = false ;
185
- },
186
- setBackgroundColor (color ) {
187
- this .options .backgroundColor = color;
188
- this .$emit (' setBackgroundColor' , color);
189
- },
190
- toggleFullscreen () {
191
- this .$emit (' toggleFullscreen' );
192
- },
193
- getLottie () {
194
- return (this .options .animation );
195
- },
196
- getPlayerState () {
197
- return (this .player .currentState );
140
+ toggleLoop () {
141
+ if (this .options .loop ) {
142
+ this .player .setLooping (false );
143
+ this .options .loop = false ;
144
+ } else {
145
+ this .player .setLooping (true );
146
+ this .options .loop = true ;
147
+ this .options .playing = true ;
148
+ this .player .play ();
198
149
}
199
150
},
200
151
setPlayerSpeed (speed ) {
@@ -219,6 +170,42 @@ export default {
219
170
getPlayerState () {
220
171
return (this .player .currentState );
221
172
}
173
+ },
174
+ mounted () {
175
+ this .player = this .$refs .player ;
176
+ this .player .addEventListener (' ready' , function () {
177
+ this .options .animation = this .player .getLottie ();
178
+ this .loading = false ;
179
+ }.bind (this ));
180
+ this .player .addEventListener (' complete' , function () {
181
+ this .stop ();
182
+ }.bind (this ));
183
+ this .options .backgroundColor = this .backgroundColor ;
184
+ this .options .speed = this .speed ;
185
+ this .options .loop = this .loop ;
186
+ this .options .playing = this .autoplay ;
187
+ },
188
+ setPlayerSpeed (speed ) {
189
+ this .player .setSpeed (speed);
190
+ this .$emit (' setPlayerSpeed' , speed);
191
+ },
192
+ stop () {
193
+ this .player .seek (1 );
194
+ this .player .stop ();
195
+ this .options .playing = false ;
196
+ },
197
+ setBackgroundColor (color ) {
198
+ this .options .backgroundColor = color;
199
+ this .$emit (' setBackgroundColor' , color);
200
+ },
201
+ toggleFullscreen () {
202
+ this .$emit (' toggleFullscreen' );
203
+ },
204
+ getLottie () {
205
+ return (this .options .animation );
206
+ },
207
+ getPlayerState () {
208
+ return (this .player .currentState );
222
209
}
223
210
}
224
211
</script >
0 commit comments