Skip to content

Commit

Permalink
re ordered if statement. Using browser standard over me.device becaus…
Browse files Browse the repository at this point in the history
…e IE will validate both pointerEnabled && msPointerEnabled.
  • Loading branch information
agmcleod committed Dec 20, 2013
1 parent 9715309 commit 0df5230
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,27 @@
me.event.publish(me.event.WINDOW_ONSCROLL, [ e ]);
}
), false);

// check for the standardized pointerEvent support
if (me.device.pointerEnabled) {
// check for backward compatibility with the 'MS' prefix
if(window.navigator.msPointerEnabled) {
activeEventList = MSPointerEventList;
} else { // standard pointerEvent support
activeEventList = pointerEventList;
}
// `touch****` events for iOS/Android devices
} else if (me.device.touch) {

// check standard
if(window.navigator.pointerEnabled) {
activeEventList = pointerEventList;
}
else if(window.navigator.msPointerEnabled) { // check for backward compatibility with the 'MS' prefix
activeEventList = MSPointerEventList;
}
else if (me.device.touch) { // `touch****` events for iOS/Android devices
activeEventList = touchEventList;
// Regular Mouse events
} else {
}
else { // Regular Mouse events
activeEventList = mouseEventList;
}

registerEventListener(activeEventList, onPointerEvent);

// detect wheel event support
// Modern browsers support "wheel", Webkit and IE support at least "mousewheel
// Modern browsers support "wheel", Webkit and IE support at least "mousewheel
wheeltype = "onwheel" in document.createElement("div") ? "wheel" : "mousewheel";
window.addEventListener(wheeltype, onMouseWheel, false);
window.addEventListener(wheeltype, onMouseWheel, false);

// set the PointerMove/touchMove/MouseMove event
if (obj.throttlingInterval === undefined) {
Expand Down

1 comment on commit 0df5230

@parasyte
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me.device.pointerEnabled could also be made a tristate instead of boolean. E.g. 0 for not enabled, 1 for standard enabled, 2 for MS-prefixed, etc.

Please sign in to comment.