-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVue-Simple-Loader.vue
157 lines (151 loc) · 3.78 KB
/
Vue-Simple-Loader.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<template>
<div v-if="inProgress" class="vue-loader-container" :style="{ height: getHeight + 'px', width: getWidth +'px' }">
<div class="vue-loader-box">
<div class="circle-in" :style="{ 'background-color': getFirstCircleColor }"></div>
<div class="circle-out" :style="{ 'background-color': getSecondCircleColor }"></div>
</div>
<p class="vue-loader-text" :style="{ color: textColor }">{{text}}</p>
</div>
</template>
<script>
export default {
name: 'Vue-Simple-Loader',
props: {
// Display or hide loader
inProgress: {
type: Boolean,
default: function(){
return false
}
},
// Text to display
text: {
type: String,
default: function(){
return '';
}
},
// Text color
textColor: {
type: String,
},
// Html element to adjust loader size to other html element
htmlElem: {
type: HTMLElement,
default: function(){
return null;
}
},
// Set a loader height
setHeight: {
type: Number,
},
// Set a loader width
setWidth: {
type: Number
},
// Set a circle colors
setColor: {
type: Object,
default: function(){
return null;
}
}
},
computed: {
// Load height
getHeight(){
return this.htmlElem !== null ? this.htmlElem.offsetHeight : this.setHeight;
},
// Load width
getWidth(){
return this.htmlElem !== null ? this.htmlElem.offsetWidth : this.setWidth;
},
// Load first circle color
getFirstCircleColor(){
return this.setColor !== null ? this.setColor.firstCircle : null;
},
// Load second circle color
getSecondCircleColor(){
return this.setColor !== null ? this.setColor.secondCircle : null;
}
}
}
</script>
<style scoped>
.vue-loader-container{
position: relative;
width:100%;
height: 100%;
}
.vue-loader-box{
width: 50%;
height: 50%;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.vue-loader-text{
text-align: center;
font-size: 50%;
bottom: 20px;
position: absolute;
width: 100%;
animation: pulse 2000ms infinite;
}
@-webkit-keyframes pulse {
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(2);
opacity: 0;
}
}
@keyframes pulse {
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(2);
opacity: 0;
}
}
.circle-in, .circle-out {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.6;
border-radius: 100%;
background-color: #1eed5c;
-webkit-animation: waving 2.0s infinite ease-in-out;
animation: waving 2.0s infinite ease-in-out;
}
.circle-out {
z-indexwebkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
@-webkit-keyframes waving {
0%, 100% {
-webkit-transform: scale(0.0)
}
50% {
-webkit-transform: scale(1.0)
}
}
@keyframes waving {
0%, 100% {
transform: scale(0.0);
-webkit-transform: scale(0.0);
}
50% {
transform: scale(1.0);
-webkit-transform: scale(1.0);
}
}
</style>