Skip to content

Commit 8405c26

Browse files
committed
fix: fixed missing spinner animation
1 parent 43840d6 commit 8405c26

File tree

5 files changed

+77
-72
lines changed

5 files changed

+77
-72
lines changed

cypress/integration/load_animation.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ context("Player component DOM check", () => {
1212
});
1313

1414
it('Loads an animation with empty URL and spinner displays.', function () {
15-
cy.get("#player-two .spinner")
16-
.should("have.class", "spinner");
15+
cy.get("#player-two .lf-spinner")
16+
.should("have.class", "lf-spinner");
1717
});
1818

1919
it('Loads an animation with invalid url.', function () {

example/components/Load.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
:showColorPicker="true"
1414
:loop="true"
1515
:autoplay="true"
16-
style="width: 100%"
1716
></lottie-vue-player>
1817

1918
<lottie-vue-player
@@ -23,7 +22,6 @@
2322
:showColorPicker="true"
2423
:loop="true"
2524
:autoplay="true"
26-
style="width: 100%; height: 400px"
2725
></lottie-vue-player>
2826

2927
<lottie-vue-player
@@ -33,7 +31,6 @@
3331
:showColorPicker="true"
3432
:loop="true"
3533
:autoplay="true"
36-
style="width: 100%; height: 400px"
3734
></lottie-vue-player>
3835

3936
<lottie-vue-player
@@ -42,7 +39,6 @@
4239
:player-controls="true"
4340
:loop="false"
4441
:autoplay="false"
45-
style="width: 100%; height: 400px"
4642
></lottie-vue-player>
4743
</div>
4844
</template>

src/Controls.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
? 'lf-fixed lf-mb-18 lf-sm:mb-0'
88
: ''
99
"
10-
class="w-full lf-pin-b lf-pin-l lf-px-3 lf-py-6"
10+
class="lf-w-full lf-pin-b lf-pin-l lf-px-3 lf-py-6"
1111
>
1212
<div class="lf-flex lf-justify-center lf-items-center lf-text-center">
1313
<!-- stop-->
@@ -223,7 +223,7 @@
223223
<input
224224
@keyup="updateBackgroundColor"
225225
v-model="backgroundColor"
226-
class="w-full text-grey-dark lf-border lf-border-grey-light bg-white lf-px-3 lf-py-2 lf-rounded-md outline-none"
226+
class="lf-w-full text-grey-dark lf-border lf-border-grey-light bg-white lf-px-3 lf-py-2 lf-rounded-md outline-none"
227227
style="font-size: 100%; box-sizing: border-box"
228228
type="text"
229229
/>

src/Player.vue

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<div class="w-full lf-relative vue-lottie-player">
2+
<div class="lf-w-full lf-relative vue-lottie-player">
33
<div
44
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"
66
>
77
<div class="lf-spinner"></div>
88
</div>
@@ -129,8 +129,6 @@ export default {
129129
},
130130
methods: {
131131
togglePlayPause() {
132-
console.log("called toggle play pause");
133-
console.log(this.options.playing);
134132
if (this.options.playing) {
135133
this.player.pause();
136134
this.options.playing = false;
@@ -139,62 +137,15 @@ export default {
139137
this.options.playing = true;
140138
}
141139
},
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();
198149
}
199150
},
200151
setPlayerSpeed(speed) {
@@ -219,6 +170,42 @@ export default {
219170
getPlayerState() {
220171
return (this.player.currentState);
221172
}
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);
222209
}
223210
}
224211
</script>

src/lottie_player.css

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@
129129
margin-bottom: 4.5rem;
130130
}
131131

132+
.lf-w-full {
133+
width: 100%;
134+
}
135+
132136
.lf-min-w-6 {
133137
min-width: 1.5rem;
134138
}
@@ -254,10 +258,28 @@
254258
border-right-color: transparent;
255259
border-radius: 50%;
256260
margin: 0 auto;
257-
-webkit-animation: rotate 0.8s linear infinite;
258-
animation: rotate 0.8s linear infinite;
261+
-webkit-animation: rotate .8s linear infinite;
262+
animation: rotate .8s linear infinite;
259263
z-index: 1;
260-
position: absolute;
264+
position: absolute
265+
}
266+
267+
@-webkit-keyframes rotate {
268+
to {
269+
-webkit-transform: rotate(1turn);
270+
transform: rotate(1turn)
271+
}
272+
}
273+
274+
@keyframes rotate {
275+
0% {
276+
-webkit-transform: rotate(0deg);
277+
transform: rotate(0deg)
278+
}
279+
to {
280+
-webkit-transform: rotate(1turn);
281+
transform: rotate(1turn)
282+
}
261283
}
262284

263285
#lf-range {
@@ -344,4 +366,4 @@
344366
.lf-sm\:mb-0 {
345367
margin-bottom: 0;
346368
}
347-
}
369+
}

0 commit comments

Comments
 (0)