ruhley / angular-color-picker

Vanilla AngularJS Color Picker Directive with no requirement on jQuery
http://ruhley.github.io/angular-color-picker/
MIT License
166 stars 79 forks source link

Touch event not being passed through - Chrome/Android and Chrome/Desktop in device(touch) mode #133

Closed dceejay closed 7 years ago

dceejay commented 7 years ago

Hi (version 2.7.1) for some reason touch events are failing to be registered when I use Chrome on Android or Chrome on Desktop in device mode... (ie simulating touch)... I get the error below in the console

Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080
preventDefault @ app.min.js:formatted:2079
value @ app.min.js:formatted:59754
value @ app.min.js:formatted:59337
dispatch @ app.min.js:formatted:1956
r.handle @ app.min.js:formatted:1883
app.min.js:formatted:59820Uncaught TypeError: Cannot read property '0' of undefined
    at t.value (app.min.js:formatted:59820)
    at t.value (app.min.js:formatted:59770)
    at t.value (app.min.js:formatted:59384)

The app.min.js:formatted:2079 corresponds to this snippet

    preventDefault: function() {
        var a = this.originalEvent;
        this.isDefaultPrevented = ga,
        a && !this.isSimulated && a.preventDefault()       <--- this line
    },

And app.min.js:formatted:59820 corresponds to the snippet below in your code (minified)

    }, {
        key: "getEventPos",
        value: function(o) {
            return 0 === o.type.search("touch") ? o.changedTouches[0] : o    <---   this line
        }
    }, {

The online note they link to is https://www.chromestatus.com/features/5093566007214080

Is there a way around this ? (I saw a similar issue closed a while ago... but I'm not sure why this has reappeared now....)

elstanto commented 7 years ago

I think o.changedTouches[0] needs to be changed to o.originalEvent.changedTouches[0]. That fixes things for me on real Android with remote Chrome debugging, and on my touch laptop with Chrome, and using simulated touches via Chrome dev tools.

dceejay commented 7 years ago

confirmed. that patch works for me also.

ruhley commented 7 years ago

Fixed and released in v2.7.2

dceejay commented 7 years ago

Thanks ! - Merry Xmas