import { Rect } from 'react-measure'; import { Gestures, PointData } from './GestureTypes'; import { NDollarRecognizer } from './ndollar'; export namespace GestureUtils { export class GestureEvent { readonly gesture: Gestures; readonly points: PointData[]; readonly bounds: Rect; readonly text?: string; constructor(gesture: Gestures, points: PointData[], bounds: Rect, text?: string) { this.gesture = gesture; this.points = points; this.bounds = bounds; this.text = text; } } export interface GestureEventDisposer { (): void; } // eslint-disable-next-line no-undef export function MakeGestureTarget(element: HTMLElement, func: (e: Event, ge: GestureEvent) => void): GestureEventDisposer { const handler = (e: Event) => func(e, (e as CustomEvent).detail); element.addEventListener('dashOnGesture', handler); return () => element.removeEventListener('dashOnGesture', handler); } export const GestureRecognizer = new NDollarRecognizer(false); }