diff options
| author | Stanley Yip <stanley_yip@brown.edu> | 2020-02-09 14:58:57 -0500 |
|---|---|---|
| committer | Stanley Yip <stanley_yip@brown.edu> | 2020-02-09 14:58:57 -0500 |
| commit | f6179334d6f2942631caa17b7c8ae2531d87c7c4 (patch) | |
| tree | 091da0ef7bedb900c958c28cebe4058fade644cf /src/pen-gestures/GestureUtils.ts | |
| parent | 07141291bee793955d7061f4e479942d7aceda67 (diff) | |
| parent | 87167fd126e161b29d8d798a5f04e3cf159aae16 (diff) | |
recommender system works
Diffstat (limited to 'src/pen-gestures/GestureUtils.ts')
| -rw-r--r-- | src/pen-gestures/GestureUtils.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/pen-gestures/GestureUtils.ts b/src/pen-gestures/GestureUtils.ts new file mode 100644 index 000000000..f14c573c3 --- /dev/null +++ b/src/pen-gestures/GestureUtils.ts @@ -0,0 +1,54 @@ +import { NDollarRecognizer } from "./ndollar"; +import { Type } from "typescript"; +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"; +import { Scripting } from "../client/util/Scripting"; + +export namespace GestureUtils { + export class GestureEvent { + constructor( + readonly gesture: Gestures, + readonly points: PointData[], + readonly bounds: Rect, + readonly callbackFn?: Function, + readonly text?: any + ) { } + } + + 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", + StartBracket = "startbracket", + EndBracket = "endbracket", + Stroke = "stroke", + Scribble = "scribble", + Text = "text" + } + + export const GestureRecognizer = new NDollarRecognizer(false); + + export function GestureOptions(name: string, gestureData?: any): (params: {}) => any { + switch (name) { + case Gestures.Box: + break; + } + throw new Error("This means that you're trying to do something with the gesture that hasn't been defined yet. Define it in GestureUtils.ts"); + } +}
\ No newline at end of file |
