visjs / vis-network

:dizzy: Display dynamic, automatically organised, customizable network views.
https://visjs.github.io/vis-network/
Apache License 2.0
3.09k stars 374 forks source link

Mobile: Using two fingers (dragging) will sometimes leave a node stuck #709

Closed cristianoccazinsp closed 4 years ago

cristianoccazinsp commented 4 years ago

Still trying to figure out what triggers the bug, but when running an example in a WebView (mobile), moving the canvas with 2 fingers while quickly tapping nodes will sometimes break a node, leaving it stuck permanently.

Is there any hidden behaviour I'm not aware of that will switch nodes to the "fixed" state?

cristianoccazinsp commented 4 years ago

Update: Just confirmed and reproduced the issue on both iOS and Android.

While dragging a node (1 finger), tap the screen with another finger, and move both fingers at the same time. After this, the node will become stuck and there's no way to drag it again.

cristianoccazinsp commented 4 years ago

Any ideas on this? Can be reproduced very easily by just tapping with a second finger while dragging with 1.

Thomaash commented 4 years ago

Long story short: It's broken and nobody managed to find the time to fix it yet.

cristianoccazinsp commented 4 years ago

Is it an old/known issue? I know I have been bothering for a while already and promising fixing stuff myself, but I may definitely tackle this one if I find the root of the problem :D

Thomaash commented 4 years ago

I don't know if it's a known issue. I didn't know about it but I'm not here all that long, there are issues unsolved all the way from Almende times.

If you want to look at it, first of all thanks, help is really appreciated here. The problem is most likely in https://github.com/visjs/vis-network/blob/master/lib/network/modules/InteractionHandler.js that's the module responsible for dragging and other interaction.

cristianoccazinsp commented 4 years ago

At first sight, I can't see anything wrong with the code (from just the above file). Debugging also doesn't show any crash/error, and in fact all events are fired with the node that's "stuck" just fine, but the node doesn't update its position.

I guess I have no other option than to download the whole source code and run it :(

cristianoccazinsp commented 4 years ago

I believe I have found the issue! The code relies on matched drag start/end event pairs. However, when dragging on a touch screen, there's a chance that two drag start events will be fired, but only one drag end, causing the node to end up "fixed".

Related lines: https://github.com/visjs/vis-network/blob/master/lib/network/modules/InteractionHandler.js#L316 https://github.com/visjs/vis-network/blob/master/lib/network/modules/InteractionHandler.js#L371 https://github.com/visjs/vis-network/blob/master/lib/network/modules/InteractionHandler.js#L411

The fix is to just prevent the drag start code from firing if already dragging. I'm not sure if adding this check would introduce any new bugs. I will test and submit a PR.

Basically, adding a line here: https://github.com/visjs/vis-network/blob/master/lib/network/modules/InteractionHandler.js#L291

if(this.drag.dragging){ return; }

Thoughts?

vis-bot commented 4 years ago

:tada: This issue has been resolved in version 7.6.10 :tada:

The release is available on:

Your semantic-release bot :package::rocket: