-
Notifications
You must be signed in to change notification settings - Fork 526
/
Copy pathrotate.html
154 lines (139 loc) · 4.43 KB
/
rotate.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PhyTouch</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html {
-ms-touch-action: none;
}
body,ul,li {
padding: 0;
margin: 0;
border: 0;
}
body {
font-size: 12px;
font-family: ubuntu, helvetica, arial;
overflow: hidden; /* this is important to prevent the whole page to bounce */
}
#header {
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: 100%;
height: 45px;
line-height: 45px;
background: #00ABEB;
padding: 0;
color: #eee;
font-size: 20px;
text-align: center;
font-weight: bold;
}
#controller, #testImg {
width: 210px; height: 210px; position: absolute; top: 50%; left: 50%; margin-left: -105px; margin-top: -105px;
}
#controller{
z-index:10;
}
#controller .right{
border:1px solid #ccc;
width:60px;
height:210px;
position:absolute;
right:0px;
}
#controller .left{
border:1px solid #ccc;
width:60px;
height:210px;
position:absolute;
left:0px;
}
#controller .top{
border:1px solid #ccc;
width:90px;
height:90px;
position:absolute;
top:0px;
left:60px;
}
#controller .bottom{
border:1px solid #ccc;
width:90px;
height:90px;
position:absolute;
bottom:0px;
left:60px;
}
#controller.noBorder .item{
border:0px solid #ccc;
}
</style>
</head>
<body>
<div id="header">PhyTouch</div>
<div style="text-align:center;position:relative;top:60px;"><button id="toogleBtn">Toogle Debug</button> </div>
<div id="controller" class="noBorder">
<div class="top item"> </div>
<div class="right item"> </div>
<div class="bottom item"> </div>
<div class="left item"> </div>
</div>
<div id="testImg">
<img style="width: 210px; height: 210px;" src="asset/lt.png" alt="" />
</div>
<a href="https://github.com/AlloyTeam/PhyTouch" target="_blank" style="position: fixed; right: 0; top: 0; z-index: 3;width:100px;height:100px;">
<img src="//alloyteam.github.io/github.png" style="width:100px;" alt="">
</a>
<script src="../transformjs/transform.js"></script>
<script src="../index.js"></script>
<script>
var target = document.querySelector("#testImg");
//给element注入transform属性
Transform(target);
new PhyTouch({
touch: "#controller .right",//反馈触摸的dom
target: target, //运动的对象
property: "rotateZ", //被滚动的属性
sensitivity: 1,//不必需,默认值是1代表touch区域的1px的对应target.y的1
change: function () { }
})
new PhyTouch({
touch: "#controller .left",//反馈触摸的dom
target: target, //运动的对象
property: "rotateZ", //被滚动的属性
sensitivity: -1,//不必需,默认值是1代表touch区域的1px的对应target.y的1
change: function () { }
})
new PhyTouch({
touch: "#controller .top",//反馈触摸的dom
vertical: false,
target: target, //运动的对象
property: "rotateZ", //被滚动的属性
sensitivity: 1,//不必需,默认值是1代表touch区域的1px的对应target.y的1
change: function () { }
})
new PhyTouch({
touch: "#controller .bottom",//反馈触摸的dom
vertical: false,
target: target, //运动的对象
property: "rotateZ", //被滚动的属性
sensitivity: -1,//不必需,默认值是1代表touch区域的1px的对应target.y的1
change: function () { }
})
var controller = document.querySelector("#controller");
document.querySelector("#toogleBtn").onclick = function () {
controller.classList.toggle("noBorder");
}
</script>
</body>
</html>