Skip to content

Instantly share code, notes, and snippets.

@x1024
Created September 14, 2013 16:28
Show Gist options
  • Save x1024/6563378 to your computer and use it in GitHub Desktop.
Save x1024/6563378 to your computer and use it in GitHub Desktop.
Initial(and untested) version of a polyfill aiming to normalize IE10/IE11 pointer events.
//
// Sources:
//
// http://benalman.com/news/2010/03/jquery-special-events/
// http://learn.jquery.com/events/event-extensions/
// https://github.com/jquery/jquery/blob/master/src/event.js#L549
// https://github.com/jquery/jquery/blob/master/src/event.js#L694
var useOldStyleEvents = window.navigator.msPointerEnabled;
if (useOldStyleEvents) {
// Add all appropriate events here, properly capitalized
var events = ['PointerDown']
for (i in events) {
var ev = events[i];
var oldEv = 'MS' + ev;
var newEv = ev.toLowerCase();
// Simulate the new-style event, but delegate it to the old-style one.
$.event.special[newEv] = {
bindType = oldEv,
delegateType = oldEv
}
}
}
@petyosi
Copy link

petyosi commented Sep 14, 2013

If I understand that correctly, the following line should read:

var useOldStyleEvents = window.navigator.msPointerEnabled && !window.navigator.pointerEnabled; 

As msPointerEnabled is true in IE11, too. We want those emulated events only in IE10.

@x1024
Copy link
Author

x1024 commented Sep 14, 2013

Ah, I did not know that. Yes, you are correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment