-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathexample.html
150 lines (133 loc) · 3.1 KB
/
example.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue Loading Bar Component</title>
<link rel="stylesheet" href="./vue-loading-bar.css">
<style>
body{
font-family: sans-serif;
}
h1{
margin-top: 95px;
}
p{
margin-bottom: 45px;
}
button{
font-size: 15px;
outline: none;
color: #0EC77A;
cursor: pointer;
border: 1px solid #0EC77A;
background: none;
border-radius: 3px;
padding: 10px 15px;
display: block;
margin: 20px auto;
}
button:hover{
color: #fff;
background: #0EC77A;
}
button.error{
color: #F11A1A;
border-color: #F11A1A;
}
button.error:hover{
color: white;
background: #F11A1A;
}
</style>
</head>
<body>
<loading-bar :progress.sync="progress" :direction="direction ? 'left' : 'right'" :error.sync="error"></loading-bar>
<div class="main">
<h1 align="center">Vue Loading Bar</h1>
<p align="center">Progress is {{ progress }}% {{ status }}</p>
<div class="button-container">
<button type="button" @click="progressTo(30)">Progress to 30</button>
<button type="button" @click="progressTo(50)">Progress to 50</button>
<button type="button" @click="progressTo(100)">Progress to 100</button>
<button type="button" @click="changeDirection">Change Direction</button>
<button class="error" type="button" @click="setToError(true)">Give An Error</button>
</div>
</div>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.14/vue.min.js"></script>
<!-- <script src="./vue-loading-bar.js"></script> -->
<script src="./vue-loading-bar.min.js"></script>
<script>
new Vue({
el: 'body',
data: function(){
return {
progress: 0,
status: "doesn't start yet",
error: false,
direction: false
};
},
methods: {
progressTo: function(val){
this.progress = val;
},
setToError: function(bol){
this.error = bol;
this.status = "Error";
},
changeDirection: function(direction){
if(this.progress > 0){
this.progress = 100;
}
this.direction = !this.direction;
}
},
events: {
/**
* Global Loading Callback Event
*
* @event-name loading-bar:{event-name}
*/
// Loading Bar on started
'loading-bar:started': function (){
console.log('started');
this.status = "started";
},
// Loading Bar on loading
'loading-bar:loading': function (){
console.log('loading');
this.status = "loading";
},
// Loading Bar on loaded
'loading-bar:loaded': function (){
console.log('loaded');
this.status = "loaded";
},
// Loading Bar on error
'loading-bar:error': function (){
console.log('error');
this.status = "error";
},
},
ready: function(){
var self = this;
self.progress = 10;
for (var i = 0; i < 30; i++) {
if(i > 20 && i < 29){
setTimeout(function () {
self.progress += 5;
},50*i);
}else{
setTimeout(function () {
self.progress ++;
},10*i);
}
}
setTimeout(function () {
self.progress = 100;
},1500);
}
});
</script>
</body>
</html>