File tree 2 files changed +37
-2
lines changed
2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 21
21
height : 300px ;
22
22
width : 300px ;
23
23
text-align : center;
24
+ position : relative;
25
+ top : 10px ;
26
+ left : 10px ;
27
+ margin-bottom : 10px ;
24
28
}
25
29
# enterleave {
26
30
background-color : blue;
32
36
left : 25% ;
33
37
top : 25% ;
34
38
position : relative;
39
+ border : 10px solid gray;
35
40
}
36
41
# output {
37
- width : 300px ;
38
42
height : 150px ;
39
43
overflow : scroll;
40
44
white-space : pre;
72
76
find ( 'capture' , 'output' , 'enterleave' ) ;
73
77
events . forEach ( function ( en ) {
74
78
capture . addEventListener ( en , function ( inEvent ) {
75
- appendOutput ( inEvent . type + ' [' + inEvent . pointerId + ']' ) ;
79
+ appendOutput ( inEvent . type + ' [' + inEvent . pointerId + ']' +
80
+ ' pageX/offsetX ' + inEvent . pageX + '/' + inEvent . offsetX +
81
+ ' pageY/offsetY ' + inEvent . pageY + '/' + inEvent . offsetY ) ;
76
82
} ) ;
77
83
} ) ;
78
84
enterleave . addEventListener ( 'pointerenter' , function ( e ) {
Original file line number Diff line number Diff line change @@ -87,6 +87,35 @@ function PointerEvent(inType, inDict) {
87
87
e . pointerType = inDict . pointerType || '' ;
88
88
e . hwTimestamp = inDict . hwTimestamp || 0 ;
89
89
e . isPrimary = inDict . isPrimary || false ;
90
+
91
+ var rect ;
92
+ function boundingClientRect ( ) {
93
+ if ( rect ) {
94
+ return rect ;
95
+ }
96
+ return ( rect = inDict . target . getBoundingClientRect ( ) ) ;
97
+ }
98
+
99
+ // CSSOM View Module's extension to mouse events
100
+ if ( inDict . offsetX === undefined ) {
101
+ Object . defineProperty ( e , 'offsetX' , {
102
+ get : function ( ) {
103
+ return e . pageX - boundingClientRect ( ) . left - inDict . target . clientLeft ;
104
+ }
105
+ } ) ;
106
+ } else {
107
+ e . offsetX = inDict . offsetX ;
108
+ }
109
+ if ( inDict . offsetY === undefined ) {
110
+ Object . defineProperty ( e , 'offsetY' , {
111
+ get : function ( ) {
112
+ return e . pageY - boundingClientRect ( ) . top - inDict . target . clientTop ;
113
+ }
114
+ } ) ;
115
+ } else {
116
+ e . offsetY = inDict . offsetY ;
117
+ }
118
+
90
119
return e ;
91
120
}
92
121
You can’t perform that action at this time.
0 commit comments