82
82
role =" region"
83
83
aria-live =" polite"
84
84
@touchstart =" onDraggableTouchStart"
85
+ @touchmove =" onDraggableTouchMove"
85
86
@touchend =" onDraggableTouchEnd"
86
87
@touchcancel =" onDraggableTouchEnd"
87
88
>
@@ -205,6 +206,8 @@ import JoinChannel from "./JoinChannel.vue";
205
206
import socket from " ../js/socket" ;
206
207
import collapseNetwork from " ../js/helpers/collapseNetwork" ;
207
208
import isIgnoredKeybind from " ../js/helpers/isIgnoredKeybind" ;
209
+ import distance from " ../js/helpers/distance" ;
210
+ import eventbus from " ../js/eventbus" ;
208
211
209
212
export default {
210
213
name: " NetworkList" ,
@@ -325,16 +328,25 @@ export default {
325
328
);
326
329
},
327
330
onDraggableChoose (event ) {
328
- if (this .isTouchEvent (event .originalEvent )) {
331
+ const original = event .originalEvent ;
332
+
333
+ if (this .isTouchEvent (original)) {
329
334
// onDrag is only triggered when the user actually moves the
330
335
// dragged object but onChoose is triggered as soon as the
331
336
// item is eligible for dragging. This gives us an opportunity
332
337
// to tell the user they've held the touch long enough.
333
338
event .item .classList .add (" ui-sortable-dragging-touch-cue" );
339
+
340
+ if (original instanceof TouchEvent && original .touches .length > 0 ) {
341
+ this .startDrag = [original .touches [0 ].clientX , original .touches [0 ].clientY ];
342
+ } else if (original instanceof PointerEvent ) {
343
+ this .startDrag = [original .clientX , original .clientY ];
344
+ }
334
345
}
335
346
},
336
347
onDraggableUnchoose (event ) {
337
348
event .item .classList .remove (" ui-sortable-dragging-touch-cue" );
349
+ this .startDrag = null ;
338
350
},
339
351
onDraggableTouchStart () {
340
352
if (event .touches .length === 1 ) {
@@ -343,6 +355,18 @@ export default {
343
355
document .body .classList .add (" force-no-select" );
344
356
}
345
357
},
358
+ onDraggableTouchMove (event ) {
359
+ if (this .startDrag && event .touches .length > 0 ) {
360
+ const touch = event .touches [0 ];
361
+ const currentPosition = [touch .clientX , touch .clientY ];
362
+
363
+ if (distance (this .startDrag , currentPosition) > 10 ) {
364
+ // Context menu is shown on Android after long touch.
365
+ // Dismiss it now that we're sure the user is dragging.
366
+ eventbus .emit (" contextmenu:cancel" );
367
+ }
368
+ }
369
+ },
346
370
onDraggableTouchEnd (event ) {
347
371
if (event .touches .length === 0 ) {
348
372
document .body .classList .remove (" force-no-select" );
0 commit comments