44 */
55
66import { DDManager } from './dd-manager' ;
7+ import { Utils } from './gridstack' ;
78
89/**
910 * Detect touch support - Windows Surface devices and other touch devices
@@ -51,26 +52,8 @@ function simulateMouseEvent(e: TouchEvent, simulatedType: string) {
5152 // Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
5253 if ( e . cancelable ) e . preventDefault ( ) ;
5354
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-
7255 // Dispatch the simulated event to the target element
73- e . target . dispatchEvent ( simulatedEvent ) ;
56+ Utils . simulateMouseEvent ( e . changedTouches [ 0 ] , simulatedType ) ;
7457}
7558
7659/**
@@ -83,29 +66,8 @@ function simulatePointerMouseEvent(e: PointerEvent, simulatedType: string) {
8366 // Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
8467 if ( e . cancelable ) e . preventDefault ( ) ;
8568
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-
10769 // Dispatch the simulated event to the target element
108- e . target . dispatchEvent ( simulatedEvent ) ;
70+ Utils . simulateMouseEvent ( e , simulatedType ) ;
10971}
11072
11173
0 commit comments