-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.html
More file actions
91 lines (90 loc) · 2.59 KB
/
test.html
File metadata and controls
91 lines (90 loc) · 2.59 KB
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<style type="text/css">
body, html{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-size: 12px;
color: white;
}
#t, #t2{
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
background: #a9dafb;
}
#t2{
left: 50px;
background: red;
}
</style>
<script src="http://code.jquery.com/jquery-git.js"></script>
<script src="jquery.mac.mousewheel.js"></script>
</head>
<body >
<div id="t">path</div>
<div id="t2">gesture</div>
<script type="text/javascript">
var $t = $("#t");
var $t2 = $("#t2");
$("body").macMouseWheel({
captureTime : 1000, //移动效果可放大缩小这个效果
//手势滑动路径,x/y
onPath : function(x, y){
//console.log('x:' + x, 'y:' + y);
var offset = $t.offset(),
top = offset.top + y,
left = offset.left + x;
$t.css({
top : top + 'px',
left : left + 'px'
})
},
//手势解析,上/下/左/右/放大/缩小
onGesture : function(gesture){
//console.log(gesture);
var offset = $t2.offset(),
top = offset.top,
left = offset.left,
width = $t2.width(),
height = $t2.height();
switch(gesture){
case 'down':
top += 50;
break;
case 'up':
top -= 50;
break;
case 'left':
left -= 50;
break;
case 'right':
left += 50;
break;
case 'zoom':
width *= 1.5;
height *= 1.5;
break;
case 'mini':
width /= 1.5;
height /= 1.5;
break;
}
$t2.css({
top : top + 'px',
left : left + 'px',
width : width,
height : height
})
}
});
</script>
</body>
</html>