(e: DragEvent | MouseEvent, info: { type: string; target?: EventTarget })
| 682 | } |
| 683 | |
| 684 | public static initEvent<T>(e: DragEvent | MouseEvent, info: { type: string; target?: EventTarget }): T { |
| 685 | const evt = { type: info.type }; |
| 686 | const obj = { |
| 687 | button: 0, |
| 688 | which: 0, |
| 689 | buttons: 1, |
| 690 | bubbles: true, |
| 691 | cancelable: true, |
| 692 | target: info.target ? info.target : e.target |
| 693 | }; |
| 694 | ['altKey','ctrlKey','metaKey','shiftKey'].forEach(p => evt[p] = e[p]); // keys |
| 695 | ['pageX','pageY','clientX','clientY','screenX','screenY'].forEach(p => evt[p] = e[p]); // point info |
| 696 | return {...evt, ...obj} as unknown as T; |
| 697 | } |
| 698 | |
| 699 | /** copies the MouseEvent (or convert Touch) properties and sends it as another event to the given target */ |
| 700 | public static simulateMouseEvent(e: MouseEvent | Touch, simulatedType: string, target?: EventTarget): void { |
no outgoing calls
no test coverage detected