This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
forked from zillow/react-slider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
155 lines (127 loc) · 3.67 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>React Slider Example</title>
<script src="node_modules/react/dist/react.js"></script>
<script src="react-slider.js"></script>
<style>
body {
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.horizontal-slider {
width: 100%;
max-width: 500px;
height: 50px;
border: 1px solid grey;
}
.vertical-slider {
height: 380px;
width: 50px;
border: 1px solid grey;
}
.handle {
font-size: 0.9em;
text-align: center;
background-color: black;
color: white;
cursor: pointer;
}
.handle.active {
background-color: grey;
}
.bar {
position: relative;
background: #ddd;
}
.bar.bar-1 {
background: #f00;
}
.bar.bar-2 {
background: #0f0;
}
.horizontal-slider .bar {
top: 20px;
height: 10px;
}
.horizontal-slider .handle {
top: 1px;
width: 50px;
height: 48px;
line-height: 48px;
}
.vertical-slider .handle {
left: 1px;
width: 48px;
line-height: 50px;
}
.vertical-slider .bar {
left: 20px;
width: 10px;
}
#horizontal-0,
#horizontal-1, #horizontal-2, #horizontal-3,
#vertical {
margin: 20px 10px;
}
#horizontal-2 .bar.bar-2 {
background: #ddd;
}
</style>
</head>
<body>
<div id="horizontal-0"></div>
<div id="horizontal-1"></div>
<div id="horizontal-2"></div>
<div id="horizontal-3"></div>
<div id="vertical"></div>
<script>
React.initializeTouchEvents(true);
var ReactSlider = React.createFactory(ReactSlider);
function map(v, f, context) {
return (v && v.map) ? v.map(f, context) : f.call(context, v, 0);
}
var Demo = React.createFactory(React.createClass({
displayName: 'Demo',
getInitialState: function () {
return {value: this.props.defaultValue}
},
onChange: function (value) {
this.setState({value: value});
},
render: function () {
return ReactSlider(
React.__spread({
className: this.props.orientation + '-slider',
pearling: true,
minDistance: 10,
value: this.state.value,
onChange: this.onChange
}, this.props),
map(this.state.value, function (value, i) {
return React.createElement('div', {key: i}, value);
})
);
}
}));
React.render(Demo({defaultValue: 0, orientation: 'horizontal'}), document.getElementById('horizontal-1'));
React.render(Demo({
defaultValue: [0, 100],
orientation: 'horizontal',
withBars: true
}), document.getElementById('horizontal-2'));
React.render(Demo({
defaultValue: [0, 50, 100],
orientation: 'horizontal',
withBars: true
}), document.getElementById('horizontal-3'));
React.render(Demo({
defaultValue: [0, 50, 100],
orientation: 'vertical',
withBars: true,
invert: true
}), document.getElementById('vertical'));
</script>
</body>
</html>