4
4
*/
5
5
6
6
import { DDManager } from './dd-manager' ;
7
+ import { Utils } from './gridstack' ;
7
8
8
9
/**
9
10
* Detect touch support - Windows Surface devices and other touch devices
@@ -51,26 +52,8 @@ function simulateMouseEvent(e: TouchEvent, simulatedType: string) {
51
52
// Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
52
53
if ( e . cancelable ) e . preventDefault ( ) ;
53
54
54
- const touch = e . changedTouches [ 0 ] , simulatedEvent = new MouseEvent ( simulatedType , {
55
- bubbles : true ,
56
- composed : true ,
57
- cancelable : true ,
58
- view : window ,
59
- detail : 1 ,
60
- screenX : touch . screenX ,
61
- screenY : touch . screenY ,
62
- clientX : touch . clientX ,
63
- clientY : touch . clientY ,
64
- ctrlKey : false ,
65
- altKey : false ,
66
- shiftKey : false ,
67
- metaKey : false ,
68
- button : 0 ,
69
- relatedTarget : null
70
- } ) ;
71
-
72
55
// Dispatch the simulated event to the target element
73
- e . target . dispatchEvent ( simulatedEvent ) ;
56
+ Utils . simulateMouseEvent ( e . changedTouches [ 0 ] , simulatedType ) ;
74
57
}
75
58
76
59
/**
@@ -83,29 +66,8 @@ function simulatePointerMouseEvent(e: PointerEvent, simulatedType: string) {
83
66
// Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
84
67
if ( e . cancelable ) e . preventDefault ( ) ;
85
68
86
- const simulatedEvent = document . createEvent ( 'MouseEvents' ) ;
87
-
88
- // Initialize the simulated mouse event using the touch event's coordinates
89
- simulatedEvent . initMouseEvent (
90
- simulatedType , // type
91
- true , // bubbles
92
- true , // cancelable
93
- window , // view
94
- 1 , // detail
95
- e . screenX , // screenX
96
- e . screenY , // screenY
97
- e . clientX , // clientX
98
- e . clientY , // clientY
99
- false , // ctrlKey
100
- false , // altKey
101
- false , // shiftKey
102
- false , // metaKey
103
- 0 , // button
104
- null // relatedTarget
105
- ) ;
106
-
107
69
// Dispatch the simulated event to the target element
108
- e . target . dispatchEvent ( simulatedEvent ) ;
70
+ Utils . simulateMouseEvent ( e , simulatedType ) ;
109
71
}
110
72
111
73
0 commit comments