Skip to content

Commit 561859c

Browse files
committed
feat: add loader animation duration option
1 parent 6cf5f44 commit 561859c

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- master
77
- dev
88
- v2-dev
9+
- extend-loader-props
910
pull_request:
1011
branches:
1112
- master
@@ -19,7 +20,7 @@ jobs:
1920
- uses: actions/checkout@v2
2021
- uses: actions/setup-node@v2
2122
with:
22-
node-version: 16.05
23+
node-version: 16
2324
- run: git branch
2425
- run: npm ci
2526
- run: npm run build
@@ -30,7 +31,7 @@ jobs:
3031
- uses: actions/checkout@v2
3132
- uses: actions/setup-node@v2
3233
with:
33-
node-version: 16.05
34+
node-version: 16
3435
- run: git branch
3536
- run: npm ci
3637
- run: npm run lint
@@ -41,6 +42,6 @@ jobs:
4142
- uses: actions/checkout@v2
4243
- uses: actions/setup-node@v2
4344
with:
44-
node-version: 16.05
45+
node-version: 16
4546
- run: npm ci
4647
- run: npm run test

src/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
animation="default 1500 1000"
5656
:hide-legend="lineMode === 'in'"
5757
:legend="-123.1"
58+
half
5859
font-size="2rem"
60+
:loader="{ duration: 5500 }"
5961
>
6062
<template #legend>
6163
<img style="width: 50px; height: 50px" src="../public/vue_ellipse.png" />

src/components/Circle/CircleLoader.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
:style="{
1414
transition: 'all',
1515
transitionTimingFunction: styles.transitionTimingFunction,
16-
transitionDuration: styles['animation-duration'],
16+
transitionDuration: `${styles['animation-duration']}ms`,
1717
transformOrigin: styles.transformOrigin,
18+
animationDuration: animationDurationStyle,
1819
'--ep-loading-stroke-offset': styles['--ep-loading-stroke-offset'],
1920
'--ep-circumference': styles['--ep-circumference'],
2021
}"
@@ -39,6 +40,12 @@ export default {
3940
opacity() {
4041
return this.options.opacity && this.options.opacity >= 0 ? this.options.opacity : 0.55;
4142
},
43+
animationDuration() {
44+
return this.options.duration && this.options.duration >= 0 ? this.options.duration : 1000;
45+
},
46+
animationDurationStyle() {
47+
return `${this.animationDuration * 2}ms, ${this.animationDuration}ms`;
48+
},
4249
loaderColor() {
4350
return Array.isArray(this.options.loader.color.colors)
4451
? `url(#ep-loader-gradient-${this.options.uid})`

src/components/Circle/HalfCircleLoader.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
:stroke-linecap="options.line"
1111
:style="{
1212
transitionTimingFunction: styles.transitionTimingFunction,
13+
transitionDuration: `${styles['animation-duration']}ms`,
1314
transformOrigin: styles.transformOrigin,
15+
animationDuration: animationDurationStyle,
1416
'--ep-loading-stroke-offset': styles['--ep-loading-stroke-offset'],
1517
'--ep-circumference': styles['--ep-circumference'],
1618
'--ep-negative-circumference': styles['--ep-negative-circumference'],
@@ -38,6 +40,12 @@ export default {
3840
opacity() {
3941
return this.options.opacity && this.options.opacity >= 0 ? this.options.opacity : 0.55;
4042
},
43+
animationDuration() {
44+
return this.options.duration && this.options.duration >= 0 ? this.options.duration : 1000;
45+
},
46+
animationDurationStyle() {
47+
return `${this.animationDuration}ms`;
48+
},
4149
halfLoaderColor() {
4250
return Array.isArray(this.options.loader.color.colors)
4351
? `url(#ep-loader-gradient-${this.options.uid})`

src/components/interface.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const colorConfig = (defaultColor = "transparent") => ({
1717

1818
const validateLoaderProps = (loaderOptions) =>
1919
Object.keys(loaderOptions).every((option) => {
20-
if (option === "opacity") {
20+
if (["opacity", "duration"].includes(option)) {
2121
return isValidNumber(loaderOptions[option]) && loaderOptions[option] >= 0;
2222
}
2323
return options[option].validator(loaderOptions[option]);
@@ -193,7 +193,7 @@ const options = {
193193
default: () => ({}),
194194
validator: (value) => {
195195
const propsAllowed = Object.keys(value).every((prop) =>
196-
["thickness", "color", "lineMode", "line", "opacity"].includes(prop)
196+
["thickness", "color", "lineMode", "line", "opacity", "duration"].includes(prop)
197197
);
198198
if (propsAllowed) {
199199
return validateLoaderProps(value);

src/styles/animationsUsage.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
&.animation__loading {
2222
animation-name: ep-progress--loading, ep-progress--loading__rotation;
2323
animation-iteration-count: infinite !important;
24-
animation-duration: 2s, 1s !important;
24+
animation-duration: 2s, 1s;
2525
animation-timing-function: ease-in-out, linear;
2626
}
2727
}
@@ -30,7 +30,7 @@
3030
&.animation__loading {
3131
animation-name: ep-half-progress--loading;
3232
animation-iteration-count: infinite !important;
33-
animation-duration: 2s !important;
33+
animation-duration: 2s;
3434
animation-timing-function: ease-in-out;
3535
}
3636
}

0 commit comments

Comments
 (0)