Skip to content

Commit 5e57029

Browse files
committed
feat: add half circle loader
1 parent dc04249 commit 5e57029

File tree

3 files changed

+58
-20
lines changed

3 files changed

+58
-20
lines changed

src/App.vue

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
line-mode="out 20"
7575
:no-data="noData"
7676
:determinate="determinate"
77+
:loader="{ thickness: 40, color: 'red' }"
7778
>
7879
<template v-slot:legend-caption>
7980
<p slot="legend-caption">TASKS DONE</p>

src/components/Circle/HalfCircle.vue

+3-20
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,7 @@
2424
</path>
2525
<fade-in-transition>
2626
<g v-if="isLoading">
27-
<g :style="{ opacity: `${options.loading ? 1 : 0.45}` }">
28-
<path
29-
:stroke-width="thickness"
30-
class="ep-half-circle--loading animation__loading"
31-
:d="path"
32-
:fill="computedColorFill"
33-
:stroke="computedColor"
34-
:stroke-dasharray="circumference"
35-
:stroke-linecap="options.line"
36-
:style="{
37-
transitionTimingFunction: styles.transitionTimingFunction,
38-
transformOrigin: styles.transformOrigin,
39-
'--ep-loading-stroke-offset': styles['--ep-loading-stroke-offset'],
40-
'--ep-circumference': styles['--ep-circumference'],
41-
'--ep-negative-circumference': styles['--ep-negative-circumference'],
42-
}"
43-
>
44-
</path>
45-
</g>
27+
<half-circle-loader :options="options.loader" />
4628
</g>
4729
</fade-in-transition>
4830

@@ -63,10 +45,11 @@
6345
<script>
6446
import CircleMixin from "./circleMixin";
6547
import FadeInTransition from "../FadeInTransition.vue";
48+
import HalfCircleLoader from "./HalfCircleLoader.vue";
6649
6750
export default {
6851
name: "HalfCircleProgress",
69-
components: { FadeInTransition },
52+
components: { HalfCircleLoader, FadeInTransition },
7053
mixins: [CircleMixin],
7154
computed: {
7255
circumference() {
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<template>
2+
<g :style="{ opacity: `${options.loading ? 1 : 0.45}` }">
3+
<path
4+
:stroke-width="thickness"
5+
class="ep-half-circle--loading animation__loading"
6+
:d="path"
7+
:fill="computedColorFill"
8+
:stroke="computedColor"
9+
:stroke-dasharray="circumference"
10+
:stroke-linecap="options.line"
11+
:style="{
12+
transitionTimingFunction: styles.transitionTimingFunction,
13+
transformOrigin: styles.transformOrigin,
14+
'--ep-loading-stroke-offset': styles['--ep-loading-stroke-offset'],
15+
'--ep-circumference': styles['--ep-circumference'],
16+
'--ep-negative-circumference': styles['--ep-negative-circumference'],
17+
}"
18+
>
19+
</path>
20+
</g>
21+
</template>
22+
<script>
23+
import CircleMixin from "./circleMixin";
24+
25+
export default {
26+
name: "HalfCircleLoader",
27+
mixins: [CircleMixin],
28+
computed: {
29+
circumference() {
30+
return (this.radius * 2 * Math.PI) / 2;
31+
},
32+
path() {
33+
return ` M ${this.position}, ${this.options.size / 2} a ${this.radius},${this.radius} 0 1,1 ${this.radius * 2},0`;
34+
},
35+
emptyPath() {
36+
return ` M ${this.emptyPosition}, ${this.options.size / 2} a ${this.emptyRadius},${this.emptyRadius} 0 1,1 ${
37+
this.emptyRadius * 2
38+
},0`;
39+
},
40+
position() {
41+
return this.options.size / 2 - this.radius;
42+
},
43+
emptyPosition() {
44+
return this.options.size / 2 - this.emptyRadius;
45+
},
46+
},
47+
};
48+
</script>
49+
50+
<style scoped lang="scss">
51+
g.ep-half-circle {
52+
transform-origin: 50% 50%;
53+
}
54+
</style>

0 commit comments

Comments
 (0)