1
interface Coordinates {
2
    x: number
3
    y: number
4
}
5

6 1
export const createMouseEvent = (type: string) => (coords: Coordinates) => {
7 1
    const event = new MouseEvent(type, {
8
        clientX: coords.x,
9
        clientY: coords.y,
10
        bubbles: true, // Must be true so that React can see it.
11
    })
12

13 1
    return event
14
}
15

16 1
export const createMouseMoveEvent = createMouseEvent('mousemove')
17 1
export const createClickEvent = createMouseEvent('click')

Read our documentation on viewing source code .

Loading