stevenwanderski / bxslider-4

Responsive jQuery content slider
Other
4.22k stars 1.85k forks source link

InvalidPointerId on Android 6 #1086

Open elektray opened 7 years ago

elektray commented 7 years ago

This is strange...

Bxslider was working all nicely on Android since today where on touch event of the carousel it fires this error "Invalid Pointer Id: Failed to execute 'set Pointer Capture' on 'Element': Invalid Pointer Id." Looking at the bxslider script this is the code where the error fires:

 if (slider.viewport.get(0).setPointerCapture) {
      slider.pointerId = orig.pointerId;
      slider.viewport.get(0).setPointerCapture(slider.pointerId);
    }

Any clue on what is going on?

elektray commented 7 years ago

Anyone can help me here?

Bxslider is the only slider that works for me, so I'm a bit desperate.

simplicitytrade commented 7 years ago

To prevent the error you could use this snippet.

var chromePointerEvents = typeof PointerEvent === 'function'; if (chromePointerEvents) { if (orig.pointerId === undefined) { return; } }

Insert before LINE 1110: touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig];

of this file: https://github.com/stevenwanderski/bxslider-4/blob/master/dist/jquery.bxslider.js

(no "official" bugfix, just a workaround for myself)

Works for me in Chrome-Browser (v55 and v56, Mac). "onTouchStart" is triggered twice in this Browser-Version im mobile emulation, once with "PointerEvent"-Event, where the "pointerId" is missing, so the following code will fail at some point.

elektray commented 7 years ago

Thanks for that. You saved me hours of pain! It works, finger crossed it will last. Just a quick note for other people, it's after line 1110 and not before ;)

bbceg commented 7 years ago

Not sure if it's worth updating the issue title to mention that this bug can be reproduced in Chrome using the mobile devices emulator. By trying various older versions it would appear it was introduced between version 4.2.1 and 4.2.3 (4.2.2 didn't appear to work at all for me).

On a related note, I notice bxslider.com is running v4.1.2, would it be worth updating that to use the latest release if not too onerous? It took me a while to realise why the examples were working when mine didn't.

Finally, I found it was only necessary to add the line to the onTouchStart function around line 1108 but so far I'm only testing in Chrome's mobile device emulator.

Hope that's helpful.

RoySegall commented 6 years ago

Worked for me as well. Thanks!