Skip to content

Commit c84a214

Browse files
authored
Merge pull request #140 from setaman/extend-loader-props
Extend loader props
2 parents 8c3f35c + ad8918a commit c84a214

File tree

7 files changed

+26
-9
lines changed

7 files changed

+26
-9
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- uses: actions/setup-node@v2
2121
with:
2222
node-version: 14.16
23-
- run: git branch
2423
- run: npm ci
2524
- run: npm run build
2625

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Sergej Atamantschuk
3+
Copyright (c) 2021 Sergej Atamantschuk
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,15 @@ Boolean that forces loading state. The component provides an indeterminate loadi
458458

459459
With this option defined as Object you can customize the loading circle that is shown in the states
460460
[loading](#loading) and [determinate](#determinate). Accepted properties are [`color`](#color), [`thickness`](#thickness), [`line`](#line),
461-
[`lineMode`](#linemode) and `opactity`. `opacity` is specific for loading circle and can be any valid CSS opacity value. If the option is not specified, the loading circle replicates the progress circle with a 0.55 default value for `opacity`.
461+
[`lineMode`](#linemode), `duration` and `opactity`. `duration` and `opacity` are specific for loading circle.
462+
Any valid CSS opacity value can be set as `opacity`. `duration` specifies the speed of the loader animation
463+
If the `loader` option is not specified, the loading circle replicates the progress circle with a 0.55 default value for `opacity`
464+
and 1000 `duration`.
462465

463466
###### Example: 📜
464467

465468
```vue
466-
<ve-progress :loader="{ color: 'green', lineMode: 'in 10', opacity: '0.6' }" />
469+
<ve-progress :loader="{ color: 'green', lineMode: 'in 10', opacity: '0.6', duration: 1500 }" />
467470
```
468471

469472
<br>

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)