diff options
| author | Stanley Yip <stanley_yip@brown.edu> | 2020-01-08 19:48:28 -0500 |
|---|---|---|
| committer | Stanley Yip <stanley_yip@brown.edu> | 2020-01-08 19:48:28 -0500 |
| commit | cef6852d597ce67637466afb36c3498dc84211f6 (patch) | |
| tree | 2799a5a973c17095b4c22f72ca8ece3ab8817b1a /src/pen-gestures | |
| parent | 685ba9666929eddac09a09e77a2e4df1322af066 (diff) | |
gestures are now overlayed and can span collections/panes!
Diffstat (limited to 'src/pen-gestures')
| -rw-r--r-- | src/pen-gestures/GestureUtils.ts | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/pen-gestures/GestureUtils.ts b/src/pen-gestures/GestureUtils.ts index 59a85b66b..4edcfa623 100644 --- a/src/pen-gestures/GestureUtils.ts +++ b/src/pen-gestures/GestureUtils.ts @@ -1,19 +1,43 @@ import { NDollarRecognizer } from "./ndollar"; import { Type } from "typescript"; -import { InkField } from "../new_fields/InkField"; +import { InkField, PointData } from "../new_fields/InkField"; import { Docs } from "../client/documents/Documents"; import { Doc, WidthSym, HeightSym } from "../new_fields/Doc"; import { NumCast } from "../new_fields/Types"; import { CollectionFreeFormView } from "../client/views/collections/collectionFreeForm/CollectionFreeFormView"; +import { Rect } from "react-measure"; export namespace GestureUtils { namespace GestureDataTypes { export type BoxData = Array<Doc>; } + export class GestureEvent { + constructor( + readonly gesture: Gestures, + readonly points: PointData[], + readonly bounds: Rect, + readonly callbackFn?: Function + ) { } + } + + export interface GestureEventDisposer { (): void; } + + export function MakeGestureTarget( + element: HTMLElement, + func: (e: Event, ge: GestureEvent) => void + ): GestureEventDisposer { + const handler = (e: Event) => func(e, (e as CustomEvent<GestureEvent>).detail); + element.addEventListener("dashOnGesture", handler); + return () => { + element.removeEventListener("dashOnGesture", handler); + } + } + export enum Gestures { Box = "box", - Line = "line" + Line = "line", + Stroke = "stroke" } export const GestureRecognizer = new NDollarRecognizer(false); |
