-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
103 lines (97 loc) · 2.09 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.wrapper {
max-width: 500px;
margin: 100px auto;
}
.range-slider {
position: relative;
width: 100%;
height: 8px;
margin: 40px 0;
background: #e6edf2;
border-radius: 8px;
user-select: none;
cursor: pointer;
}
.progress {
background: #2196f3;
border-radius: 8px;
height: 100%;
}
.thumb {
position: relative;
background: #fff;
box-shadow: 0 0 10px -2px #aaa;
width: 20px;
height: 20px;
border-radius: 20px;
margin-top: -14px;
transform: translateX(-10px);
}
.thumb::after,
.thumb::before {
content: " ";
position: absolute;
left: 8px;
top: 6px;
height: 8px;
border-left: 1px solid #2196f3;
}
.thumb::after {
left: 11px;
}
.value {
top: -40px;
transform: translateX(-50%);
color: #2196f3;
box-shadow: 0 0 10px -2px #aaa;
border-radius: 4px;
height: 20px;
line-height: 20px;
padding: 0 10px;
text-align: center;
white-space: nowrap;
}
</style>
</head>
<body>
<div id="app">Loading...</div>
<script src="//lib.baomitu.com/vue/2.0.5/vue.js"></script>
<script src="./dist/index.js"></script>
<script>
new Vue({
el: '#app',
template: `
<div class="wrapper">
<v-ctrl direction="h" :throttle="80" @change="onChange">
<div class="range-slider">
<div class="progress" :style="{ width: percentage }"></div>
<div class="thumb" :style="{ left: percentage }"></div>
</div>
</v-ctrl>
<p>{{value}}</p>
</div>`,
data: {
value: 20
},
computed: {
percentage () {
return `${this.value}%`
}
},
methods: {
onChange (val) {
this.value = Math.round(val * 100)
}
}
})
</script>
</body>
</html>