aboutsummaryrefslogtreecommitdiff
path: root/src/pen-gestures
diff options
context:
space:
mode:
authorStanley Yip <33562077+yipstanley@users.noreply.github.com>2020-01-20 17:30:37 -0500
committerGitHub <noreply@github.com>2020-01-20 17:30:37 -0500
commit65c0769d420841765cb9545a4c99213c4433e7af (patch)
treecec7e1ea69596513c373c2245610b5e4a679da56 /src/pen-gestures
parentcc2cbf44ba5c30a70bad2ffd7a57d2c6d17d0e4e (diff)
parent758d960b4251672c9615b0bf53ea992065ca524b (diff)
Merge pull request #331 from browngraphicslab/pen
Pen
Diffstat (limited to 'src/pen-gestures')
-rw-r--r--src/pen-gestures/GestureUtils.ts29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/pen-gestures/GestureUtils.ts b/src/pen-gestures/GestureUtils.ts
index 59a85b66b..4b5ad6684 100644
--- a/src/pen-gestures/GestureUtils.ts
+++ b/src/pen-gestures/GestureUtils.ts
@@ -1,19 +1,44 @@
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",
+ Scribble = "scribble"
}
export const GestureRecognizer = new NDollarRecognizer(false);