-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
156 lines (135 loc) · 5.2 KB
/
test.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
156
<!DOCTYPE html>
<html>
<title>租来租去</title>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="租来租去" />
<meta name="keywords" content="租来租去" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" type="text/css" href="resource/hih5/css/main.css" />
<link rel="stylesheet" type="text/css" href="resource/hih5/css/main.css" />
<link rel="stylesheet" type="text/css" href="resource/zlzq/css/zlzq.css"/>
<link rel="stylesheet" type="text/css" href="resource/zlzq/css/custom.css">
<body>
<div id="headerview" style="height: 48px;">
</div>
<div class="type-bar-box" style="visibility: visible">
<div>
<div class="type-bar" style=" transform: translate(0,0%);">
<div class="control">
<!--<h2>租金<em>(元/月)</em></h2>-->
<div style="margin-top: 35px">
<div class="range-bar disable_text_highlighting">
<div class="range-start-icon"></div>
<div style="height: 30px; border: solid 1px;" id="range">
<div class="range-icon" id="icon" style="top: 50px;background: #ff6c10;left: 5px;;"></div>
</div>
<div class="range-inner-bar"></div>
</div>
</div>
</div>
<div class="control" >
<h2>房型</h2>
<ul class="house-type">
<li><div>1室</div></li>
<li><div>2室</div></li>
<li><div>3室</div></li>
<li><div>4室以上</div></li>
</ul>
</div>
<div class="control">
<a>重置</a> <a class="yes">确定</a>
</div>
<div class="control" id="test"></div>
</div>
</div>
</div>
<script style="text/javascript">
var hasTouch = 'ontouchstart' in window,
START_EV = hasTouch ? 'touchstart' : 'mousedown',
MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
END_EV = hasTouch ? 'touchend' : 'mouseup',
CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup';
var t= function (opt) {
var that = this;
that.el = document.getElementById("range");
that.x=0;
that._bind(START_EV);
}
t.prototype= {
handleEvent: function (e) {
var that = this;
switch (e.type) {
case START_EV:
if (!hasTouch && e.button !== 0) return;
that._start(e);
break;
case MOVE_EV:
that._move(e);
break;
case END_EV:
case CANCEL_EV:
that._end(e);
break;
case 'mouseout':
that._mouseout(e);
break;
case 'webkitTransitionEnd':
that._transitionEnd(e);
break;
}
},
_start: function (e) {
var that=this;
if(!e.target.classList.contains("range-icon")){
return;
}
point = hasTouch ? e.touches[0] : e;
that.pointX = point.pageX;
that.pointY = point.pageY;
that.distX = 0;
that.distY = 0;
that.absDistX = 0;
that.absDistY = 0;
that._bind(MOVE_EV);
that._bind(END_EV);
},
_move: function (e) {
var that = this,
point = hasTouch ? e.touches[0] : e,
deltaX = point.pageX - that.pointX,
deltaY = point.pageY - that.pointY,
newX = that.x + deltaX,
newY = that.y + deltaY;
that.pointX = point.pageX;
that.pointY = point.pageY;
that.distX += deltaX;
that.distY += deltaY;
that.absDistX = Math.abs(that.distX);
that.absDistY = Math.abs(that.distY);
if (that.absDistX < 6 && that.absDistY < 6) {
return;
}
this.x = newX;
this.y = newY;
document.getElementById("test").innerHTML = deltaX;
document.getElementById("icon").style.left = this.x + "px";
},
_end: function (e) {
var that=this;
that._unbind(MOVE_EV);
that._unbind(END_EV);
},
_bind: function (type, el, bubble) {
(el || this.el).addEventListener(type, this, !!bubble);
},
_unbind: function (type, el, bubble) {
(el || this.el).removeEventListener(type, this, !!bubble);
}
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
new t();
</script>
</body>
</html>