mudcube / Event.js

:hand: Multi-touch, gestures, and other events—click, dblclick, dbltap, tap, longpress, drag, swipe, pinch, rotate, shake. For pointer events, each listener can handle anywhere from 1 to 12 fingers at a time, or more, depending on the device. Includes MetaKey tracking (CMD, CTRL) to support native key-commands in various platforms.
MIT License
368 stars 68 forks source link

Support for IE8 #12

Closed Kienz closed 9 years ago

Kienz commented 10 years ago

window.getComputedStyle and style.getPropertyValue are not supported in IE <= 8. You can just use something like that - code is from fabric.js

var getElementStyle;
if (document.defaultView && document.defaultView.getComputedStyle) {
  getElementStyle = function(element, attr) {
    var style = document.defaultView.getComputedStyle(element, null);
    return style ? style[attr] : undefined;
  };
}
else {
  getElementStyle = function(element, attr) {
    var value = element.style[attr];
    if (!value && element.currentStyle) {
      value = element.currentStyle[attr];
    }
    return value;
  };
}
mudcube commented 9 years ago

Howdy Kienz,

I'll make a mention of that on the README. I'm not interested in including a polyfill in the code (as other modules may also require a feature and then you have multiple polyfills filling the same gaps in the browser).

I recommend to polyfill the browser support for the missing feature instead. In my own projects I use this polyfill: https://github.com/jonathantneal/Polyfills-for-IE8/blob/master/getComputedStyle.js

Which is part of the polyfill.io service (worth checking out)