yoannmoinet / nipplejs

:video_game: A virtual joystick for touch capable interfaces.
https://yoannmoinet.github.io/nipplejs
MIT License
1.78k stars 185 forks source link

[BUG] Dynamic joysticks freezes on fast interaction #151

Open caiiiycuk opened 4 years ago

caiiiycuk commented 4 years ago

Hi.

Describe the bug Dynamic joysticks freeze at some time if you interact fastly. This bug reproduced on nipple js website.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://yoannmoi.net/nipplejs/
  2. Fast interact with in dynamic mode
  3. You should see some joysticks that are in freeze

Expected behavior Joysticks should not freeze

Screenshots, Codepen or JSFiddle Video: https://youtu.be/Rq1NxbSgD0I

Desktop (please complete the following information):

Smartphone (please complete the following information):

caiiiycuk commented 4 years ago

I found that problem is exactly same as in https://github.com/yoannmoinet/nipplejs/issues/94, but for pointer events. Affected devices sometimes does not send pointerremove event. But seems that workaround as for touch events is not possible because we can't get ids of current pointers.

As workaround I switched to "touch" mode for default:

var toBind;
var secondBind = {};
if (isTouch) {
    toBind = events.touch;
    secondBind = events.mouse;
} else if (isPointer) {
    toBind = events.pointer;
} else if (isMSPointer) {
    toBind = events.MSPointer;
} else {
    toBind = events.mouse;
}

This helps. I think it could be good if this order can be configurable. Why pointer is preferred over touch?

caiiiycuk commented 4 years ago

I found that pointer events works much better then touch events. I added partial workaround for single touch mode it works fine in my case. Please look PR.