-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointerevents_issue327.html
87 lines (77 loc) · 1.88 KB
/
pointerevents_issue327.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>
<head>
<meta charset="utf-8"/>
<link rel="help" href="https://github.com/w3c/pointerevents/issues/327">
<style>
div.box {
margin: 5px;
padding: 20px;
float: left;
background-color:green;
}
#grey {
width: 50px;
height: 50px;
}
#log{
float: left;
overflow: auto;
height:600px;
}
</style>
</head>
<body>
<div id="grey" class="box" style="background-color:grey">
<div id="green" class="box"></div>
</div>
<div id="log">
</div>
<script>
var greyDiv = document.getElementById("grey");
var greenDiv = document.getElementById("green");
var logDiv = document.getElementById("log");
function addLog(message){
var para = document.createElement("div");
var textNode = document.createTextNode(message);
para.appendChild(textNode);
logDiv.appendChild(para);
}
greenDiv.addEventListener("pointerdown",(e)=>{
console.log("pointerdown@green");
if(greenDiv.hasPointerCapture(e.pointerId)){
addLog("greenDiv has pointer capture");
greenDiv.releasePointerCapture(e.pointerId);
}
});
greyDiv.addEventListener("pointerdown", (e)=>{
addLog("pointerdown@grey");
greyDiv.setPointerCapture(e.pointerId);
});
greyDiv.addEventListener("gotpointercapture",(e)=>{
addLog("greyDiv - gotpointercapture");
});
greyDiv.addEventListener("lostpointercapture",(e)=>{
addLog("greyDiv - lostpointercapture");
});
greenDiv.addEventListener("gotpointercapture",(e)=>{
addLog("greenDiv - gotpointercapture");
});
greenDiv.addEventListener("lostpointercapture",(e)=>{
addLog("greenDiv - lostpointercapture");
});
greenDiv.addEventListener("pointermove", (e)=>{
addLog("greenDiv - pointermove");
});
greenDiv.addEventListener("pointerup", (e)=>{
addLog("greenDiv - pointerup");
});
greyDiv.addEventListener("pointermove", (e)=>{
addLog("greyDiv - pointermove");
});
greyDiv.addEventListener("pointerup", (e)=>{
addLog("greyDiv - pointerup");
});
</script>
</body>
</html>