-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths2.html
210 lines (182 loc) · 5.63 KB
/
s2.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<html>
<head data-page="user_login" path="">
<title>scroller</title>
<style type="text/css">
*{margin:0;padding:0;border:none;color:white;}
.J-wrap{
-webkit-transform-style: preserve-3d;-webkit-backface-visibility:hidden;
position:relative;overflow:hidden;height:320px;border:1px solid white;
width:300px;
float:left;margin:0 10px 0 0
}
.J-scroll{
position:absolute;width:100%;
-webkit-backface-visibility:hidden;-webkit-perspective: 1000;
-webkit-transform: translateY(0px);-webkit-transform-style: preserve-3d;
}
.J-scroll li{height:40px;line-height: 40px;text-align: center}
</style>
</head>
<body style="background:#333">
<div class="J-wrap">
<div id="J-scroll" class="J-scroll">
<ul>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
<li><a href="#">items block</a></li>
</ul>
</div>
</div>
<script>
var getPrefix = function() {//-webkit-
var sty = document.body.style;
var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'],
len = vendorPrefixes.length,
vendor = '';
while (len--)
if ((vendorPrefixes[len] + 'Transform') in sty)
vendor='-'+vendorPrefixes[len].toLowerCase()+'-';
return vendor;
}
</script>
<script>
;(function(win,D,undefined){
var isTouch = 'ontouchstart' in win;
function momentum(current, start, time, lowerMargin, wrapperSize) {
/* from iscroll */
var distance = current - start,
speed = Math.abs(distance) / time,
destination,
duration,
deceleration = 0.00096;
destination = current + (speed * speed) / (2 * deceleration) * (distance < 0 ? -1 : 1);
duration = speed / deceleration;
if (destination < lowerMargin) {
destination = wrapperSize ? lowerMargin - (wrapperSize / 2.5 * (speed / 8)) : lowerMargin;
distance = Math.abs(destination - current);
duration = distance / speed;
} else if (destination > 0) {
destination = wrapperSize ? wrapperSize / 2.5 * (speed / 8) : 0;
distance = Math.abs(current) + destination;
duration = distance / speed;
}
return {
destination: Math.round(destination),
duration: duration
}
}
function getPos(lay) {
var matrix = win.getComputedStyle(lay, null), x, y;
matrix = matrix['-webkit-transform'].split(')')[0].split(', ');
x = +(matrix[12] || matrix[4]);
y = +(matrix[13] || matrix[5]);
return {y: y ,x:x};
}
var direction=function(flag){
}
function Scroller(el,opts){
var lay=this.lay=typeof el == 'string' ? D.getElementById(el) : el;
lay.style.webkitTransitionTimingFunction = 'cubic-bezier(0.1, 0.57, 0.1, 1)';
this.y = 0;this.x = 0;
this.init(opts);
this.setup();
};
Scroller.prototype={
init:function(opts){
var pre="translate3d";
var flag= this.flag=opts.H ? true:false;
this.wHW= flag ? this.lay.parentNode.clientHeight:this.lay.parentNode.clientWidth;
this.sHW= flag ? this.lay.offsetHeight:this.lay.offsetWidth;
this.maxScrollXY = this.wHW - this.sHW;
this.trans=(function(self){
return flag ? function(y){
self.y=y;
return pre+'(0px,'+y+'px,0px)'
}:function(x){
self.x=x;
return pre+'('+x+'px,0px,0px)'
}
})(this);
},
setup:function(args){
var type=args?'removeEventListener':'addEventListener';
args && this.scrollTo(0);
this.lay[type]('touchstart', this, false);
this.lay[type]('touchmove', this, false);
this.lay[type]('touchend', this, false);
this.lay[type]('touchcancel', this, false);
this.lay[type]('webkitTransitionEnd', this, false);
win[type]('onorientationchange' in win ? 'orientationchange':'resize',this,false);
},
handleEvent: function(e) {
switch (e.type) {
case 'touchstart': this._start(e); break;
case 'touchmove': this._mov(e); break;
case 'touchcancel' :
case 'touchend': this._end(e); break;
case 'webkitTransitionEnd':this._movend(e);break
case 'resize':
case 'orientationchange':this._resize(e);break;
}
},
_start:function(e){
//if(e.target.tagName=="A"){return}
this.startTime = +new Date;
if (!!this.isMoving) {
this.scrollTo(getPos(this.lay).y);
}
this.startY = this.y;
this.startX = this.x;
this.pointY = e.touches[0].pageY;
this.pointX = e.touches[0].pageX;
},
_mov:function(e){
var eth=e.touches[0];
e.preventDefault();
var deltaY = eth.pageY - this.pointY,newY;
var deltaX = eth.pageX - this.pointX,newX;
this.pointY = eth.pageY;
this.pointX = eth.pageX;
newY = this.y + deltaY;
newX = this.x + deltaX;
this.scrollTo(this.flag ? newY : newX);
},
_end:function(){
this.isMoving = 0;
},
_movend:function(){
},
scrollTo:function(xy,time){
this.lay.style.webkitTransitionDuration = time||0 + 'ms';
this.lay.style.webkitTransform=this.trans(xy);
}
}
window.Scroller=Scroller;
})(window,document);
var me=new Scroller('J-scroll',{
H:true,
continues:false
});
</script>
</body>
</html>