Skip to content

Commit fd33db3

Browse files
committed
Pointer: Change pointerType strings and better determine isPrimary
1 parent 95c2986 commit fd33db3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

external/pointer.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(function( $ ) {
2-
var POINTER_TYPE_UNAVAILABLE = "1",
3-
POINTER_TYPE_TOUCH = "2",
4-
POINTER_TYPE_PEN = "3",
5-
POINTER_TYPE_MOUSE = "4";
2+
var POINTER_TYPE_UNAVAILABLE = "",
3+
POINTER_TYPE_TOUCH = "touch",
4+
POINTER_TYPE_PEN = "pen",
5+
POINTER_TYPE_MOUSE = "mouse";
66

77
function processEvent( event, pointerType ) {
88
var propLength,
@@ -20,8 +20,7 @@ function processEvent( event, pointerType ) {
2020
tiltX: 0,
2121
tiltY: 0,
2222
pointerType: "",
23-
// TODO: properly determine isPrimary
24-
isPrimary: true
23+
isPrimary: false
2524
});
2625

2726
for ( propLength = mouseProps.length; i < propLength; i++ ) {
@@ -34,12 +33,15 @@ function processEvent( event, pointerType ) {
3433
// TODO: Don't assume left click
3534
event.button = 0;
3635
event.buttons = 1;
36+
event.isPrimary = true;
3737
} else if ( orig.type.indexOf("touch") !== -1 ) {
3838
event.pointerId = orig.pointerId;
3939
event.pointerType = POINTER_TYPE_TOUCH;
4040
event.button = 0;
4141
event.buttons = 1;
4242
event.originalEvent = orig;
43+
// TODO: Properly determine primary pointer
44+
event.isPrimary = true;
4345
} else if ( orig.type.indexOf("Pointer") !== -1 ) {
4446
event.pointerId = orig.originalEvent.pointerId;
4547
event.pointerType = orig.originalEvent.pointerType || POINTER_TYPE_UNAVAILABLE;
@@ -50,6 +52,7 @@ function processEvent( event, pointerType ) {
5052
event.pressure = orig.originalEvent.pressure;
5153
event.tiltX = orig.originalEvent.tiltX;
5254
event.tiltY = orig.originalEvent.tiltY;
55+
event.isPrimary = orig.originalEvent.isPrimary;
5356
}
5457

5558
return event;

0 commit comments

Comments
 (0)