@@ -11,15 +11,15 @@ import { DDManager } from './dd-manager';
11
11
* /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
12
12
*/
13
13
export const isTouch : boolean = typeof window !== 'undefined' && typeof document !== 'undefined' &&
14
- ( 'ontouchstart' in document
15
- || 'ontouchstart' in window
16
- // || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- || ( ( window as any ) . DocumentTouch && document instanceof ( window as any ) . DocumentTouch )
19
- || navigator . maxTouchPoints > 0
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- || ( navigator as any ) . msMaxTouchPoints > 0
22
- ) ;
14
+ ( 'ontouchstart' in document
15
+ || 'ontouchstart' in window
16
+ // || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ || ( ( window as any ) . DocumentTouch && document instanceof ( window as any ) . DocumentTouch )
19
+ || navigator . maxTouchPoints > 0
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ || ( navigator as any ) . msMaxTouchPoints > 0
22
+ ) ;
23
23
24
24
// interface TouchCoord {x: number, y: number};
25
25
@@ -51,26 +51,23 @@ function simulateMouseEvent(e: TouchEvent, simulatedType: string) {
51
51
// Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
52
52
if ( e . cancelable ) e . preventDefault ( ) ;
53
53
54
- const touch = e . changedTouches [ 0 ] , simulatedEvent = document . createEvent ( 'MouseEvents' ) ;
55
-
56
- // Initialize the simulated mouse event using the touch event's coordinates
57
- simulatedEvent . initMouseEvent (
58
- simulatedType , // type
59
- true , // bubbles
60
- true , // cancelable
61
- window , // view
62
- 1 , // detail
63
- touch . screenX , // screenX
64
- touch . screenY , // screenY
65
- touch . clientX , // clientX
66
- touch . clientY , // clientY
67
- false , // ctrlKey
68
- false , // altKey
69
- false , // shiftKey
70
- false , // metaKey
71
- 0 , // button
72
- null // relatedTarget
73
- ) ;
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
+ } ) ;
74
71
75
72
// Dispatch the simulated event to the target element
76
73
e . target . dispatchEvent ( simulatedEvent ) ;
0 commit comments