aboutsummaryrefslogtreecommitdiff
path: root/src/pen-gestures
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-04-17 12:27:21 -0400
committerbobzel <zzzman@gmail.com>2024-04-17 12:27:21 -0400
commit2a313f28fcb8675223708b0657de7517a3281095 (patch)
treeed6db226cc7d323aee378eddee43dc5f3bdb1ef9 /src/pen-gestures
parent62937027183dc8acf14e489fbb4590aff6fce2cd (diff)
restoring eslint - updates not complete yet
Diffstat (limited to 'src/pen-gestures')
-rw-r--r--src/pen-gestures/GestureTypes.ts16
-rw-r--r--src/pen-gestures/GestureUtils.ts26
-rw-r--r--src/pen-gestures/ndollar.ts10
3 files changed, 34 insertions, 18 deletions
diff --git a/src/pen-gestures/GestureTypes.ts b/src/pen-gestures/GestureTypes.ts
new file mode 100644
index 000000000..d86562580
--- /dev/null
+++ b/src/pen-gestures/GestureTypes.ts
@@ -0,0 +1,16 @@
+export enum Gestures {
+ Line = 'line',
+ Stroke = 'stroke',
+ Scribble = 'scribble',
+ Text = 'text',
+ Triangle = 'triangle',
+ Circle = 'circle',
+ Rectangle = 'rectangle',
+ Arrow = 'arrow',
+}
+
+// Defines a point in an ink as a pair of x- and y-coordinates.
+export interface PointData {
+ X: number;
+ Y: number;
+}
diff --git a/src/pen-gestures/GestureUtils.ts b/src/pen-gestures/GestureUtils.ts
index 41917aac9..28323d62f 100644
--- a/src/pen-gestures/GestureUtils.ts
+++ b/src/pen-gestures/GestureUtils.ts
@@ -1,32 +1,32 @@
import { Rect } from 'react-measure';
-import { PointData } from '../fields/InkField';
+import { Gestures, PointData } from './GestureTypes';
import { NDollarRecognizer } from './ndollar';
export namespace GestureUtils {
export class GestureEvent {
- constructor(readonly gesture: Gestures, readonly points: PointData[], readonly bounds: Rect, readonly text?: any) {}
+ readonly gesture: Gestures;
+ readonly points: PointData[];
+ readonly bounds: Rect;
+ readonly text?: any;
+
+ constructor(gesture: Gestures, points: PointData[], bounds: Rect, text?: any) {
+ 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<GestureEvent>).detail);
element.addEventListener('dashOnGesture', handler);
return () => element.removeEventListener('dashOnGesture', handler);
}
- export enum Gestures {
- Line = 'line',
- Stroke = 'stroke',
- Scribble = 'scribble',
- Text = 'text',
- Triangle = 'triangle',
- Circle = 'circle',
- Rectangle = 'rectangle',
- Arrow = 'arrow',
- }
-
export const GestureRecognizer = new NDollarRecognizer(false);
}
diff --git a/src/pen-gestures/ndollar.ts b/src/pen-gestures/ndollar.ts
index 3ee9506cb..d28d303b8 100644
--- a/src/pen-gestures/ndollar.ts
+++ b/src/pen-gestures/ndollar.ts
@@ -1,4 +1,4 @@
-import { GestureUtils } from './GestureUtils';
+import { Gestures } from './GestureTypes';
/**
* The $N Multistroke Recognizer (JavaScript version)
@@ -172,7 +172,7 @@ export class NDollarRecognizer {
//
this.Multistrokes.push(
new Multistroke(
- GestureUtils.Gestures.Rectangle,
+ Gestures.Rectangle,
useBoundedRotationInvariance,
new Array(
new Array(
@@ -185,17 +185,17 @@ export class NDollarRecognizer {
)
)
);
- this.Multistrokes.push(new Multistroke(GestureUtils.Gestures.Line, useBoundedRotationInvariance, new Array(new Array(new Point(12, 347), new Point(119, 347)))));
+ this.Multistrokes.push(new Multistroke(Gestures.Line, useBoundedRotationInvariance, new Array(new Array(new Point(12, 347), new Point(119, 347)))));
this.Multistrokes.push(
new Multistroke(
- GestureUtils.Gestures.Triangle, // equilateral
+ Gestures.Triangle, // equilateral
useBoundedRotationInvariance,
new Array(new Array(new Point(40, 100), new Point(100, 200), new Point(140, 102), new Point(42, 100)))
)
);
this.Multistrokes.push(
new Multistroke(
- GestureUtils.Gestures.Circle,
+ Gestures.Circle,
useBoundedRotationInvariance,
new Array(
new Array(