stephband/jquery.event.move

[].indexOf is used in plugin breaks IE8

Closed this issue · 3 comments

Array.prototype.indexOf is not implemented in IE8, so plugin produces error in this browser.

Fixed it with:

if (typeof(Array.prototype.indexOf) === 'function') { // IE8 does not have indexOf() on Array.
    (function(jQuery, undefined){
        var props = ["changedTouches", "targetTouches"],
            l = props.length;

        while (l--) {
            if (jQuery.event.props.indexOf(props[l]) === -1) {
                jQuery.event.props.push(props[l]);
            }
        }
    })(jQuery);
};

Yeah. Unfortunately that fix will stop move events working in touch devices. There are two fixes for this:

  1. Include es5-shim (https://github.com/kriskowal/es5-shim) in your project, which patches up IE with polyfills for missing JavaScript methods. That's what I do.

  2. Find all the points where the properties 'e.changedTouches' and 'e.targetTouches' are being read from event objects, and swap them for 'e.originalEvent.changedTouches' and 'e.originalEvent.targetTouches'. Seems like a quick win. Any volunteers?

@tvdeyen Yeah, actually, I see the assumption does make sense. Touch devices have .indexOf(), so it won't break touch devices at all. My bad. Ok, I'll go with that.

Fixed:
2d3ff7d

Cheers!