forked from scottgonzalez/dev-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpointer-events.html
80 lines (69 loc) · 1.37 KB
/
pointer-events.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pointer/Touch/Mouse Events</title>
<style>
p {
margin: 0;
padding: 0;
}
</style>
<script>
window.onload = function() {
var events = [
"mousedown",
"mousemove",
"mouseup",
"mouseover",
"mouseout",
"mouseenter",
"mouseleave",
"touchstart",
"touchmove",
"touchend",
"touchcancel",
"pointerdown",
"pointermove",
"pointerup",
"pointercancel",
"pointerover",
"pointerout",
"pointerenter",
"pointerleave",
"MSPointerDown",
"MSPointerMove",
"MSPointerUp",
"MSPointerCancel",
"MSPointerOver",
"MSPointerOut",
"MSPointerEnter",
"MSPointerLeave",
"MSPointerHover",
"click",
"dblclick",
"contextmenu"
];
var outerElem = document.getElementById( "outer" );
for ( var i = 0; i < events.length; i++ ) {
outerElem.addEventListener( events[ i ], log );
}
var logElem = document.getElementById( "log" );
function log( event ) {
var p = document.createElement( "p" );
p.innerHTML = event.type + " - " + event.target.id;
logElem.insertBefore( p, logElem.firstChild );
console.log( event.type, event );
};
};
</script>
</head>
<body id="body">
<div id="outer" style="padding: 50px; background: #aaf;">
<div id="inner" style="width: 200px; height: 100px; background: #afa;">
<input id="input">
</div>
</div>
<div id="log"></div>
</body>
</html>