-
Notifications
You must be signed in to change notification settings - Fork 1
/
index-dev.html
87 lines (71 loc) · 2.37 KB
/
index-dev.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Touch Framework Example</title>
<style type="text/css">
#triggerArea,
#logger {
display:block;
width:47%;
height:400px;
border:1px solid #333;
margin:0;
}
#triggerArea {
float:left;
margin-right:0.5%;
}
#logger {
float:right;
margin-left:0.5%;
overflow-y:auto;
}
</style>
<script src="http://localhost:8080/target/target-script-min.js#anonymous"></script>
<script type="text/javascript" src="js/TouchLayerController.js"></script>
<script type="text/javascript" src="js/TapController.js"></script>
<script type="text/javascript" src="js/DragController.js"></script>
<script type="text/javascript" src="js/SwipeController.js"></script>
<script type="text/javascript" src="js/touchLayer.js"></script>
</head>
<body>
<h1>Touch Framework experiments</h1>
<div id="triggerArea"><br/><br/><br/><a href="#test">test click</a></div>
<ul id="logger"></ul>
<script type="text/javascript">
var logger = document.getElementById('logger');
var target = document.getElementById('triggerArea');
var touchLayer = new TouchLayer();
var id = 0;
var callback = function(event) {
console.log(event);
var element = document.createElement('li'),
str = event.type;
if (event.type === 'swipe' && event.data) {
str += ' direction:' + event.data.direction + ' deltaX:' + event.data.deltaX + ' deltaTime:' + event.data.deltaTime;
} else if (event.type === 'drag' && event.data) {
str += ' direction:' + event.data.direction;
}
element.innerHTML = str;
if (logger.childNodes.length > 0) {
logger.insertBefore(element, logger.childNodes[0]);
} else {
logger.appendChild(element);
}
//touchLayer.unbind(id);
};
touchLayer.bind('tapstart', target, callback);
touchLayer.bind('tapcancel', target, callback);
touchLayer.bind('tap', target, callback);
touchLayer.bind('taphold', target, callback);
touchLayer.bind('doubletap', target, callback);
touchLayer.bind('singletap', target, callback);
touchLayer.bind('drag', target, callback);
touchLayer.bind('twofingerdrag', target, callback);
touchLayer.bind('dragstart', target, callback);
touchLayer.bind('dragend', target, callback);
touchLayer.bind('swipe', target, callback, { swipeVertical: true });
</script>
</body>
</html>