aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-12-07 14:48:43 -0500
committeryipstanley <stanley_yip@brown.edu>2019-12-07 14:48:43 -0500
commitb3b81c8400ce2a92df1ae8c0db9b422cf4a2cf4c (patch)
tree99cc7d7636eb1cd2937b0d9e4211a3e1bc9e12cd
parentfb9f08295c10c35c11b647d00a3c830867dc3f7d (diff)
i think this is better now
-rw-r--r--src/client/util/InteractionUtils.ts2
-rw-r--r--src/client/views/Touchable.tsx33
-rw-r--r--src/pen-gestures/GestureUtils.ts8
3 files changed, 19 insertions, 24 deletions
diff --git a/src/client/util/InteractionUtils.ts b/src/client/util/InteractionUtils.ts
index c24c70bca..7390890c6 100644
--- a/src/client/util/InteractionUtils.ts
+++ b/src/client/util/InteractionUtils.ts
@@ -53,7 +53,7 @@ export namespace InteractionUtils {
* @param oldPoint2 - previous point 2
*/
export function Pinching(pt1: React.Touch, pt2: React.Touch, oldPoint1: React.Touch, oldPoint2: React.Touch): number {
- let threshold = 4;
+ let threshold = 3;
let oldDist = TwoPointEuclidist(oldPoint1, oldPoint2);
let newDist = TwoPointEuclidist(pt1, pt2);
diff --git a/src/client/views/Touchable.tsx b/src/client/views/Touchable.tsx
index d0e3db8a5..5dcfec768 100644
--- a/src/client/views/Touchable.tsx
+++ b/src/client/views/Touchable.tsx
@@ -26,7 +26,8 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
}
if (this.prevPoints.size) {
- switch (e.targetTouches.length) {
+ console.log(e.targetTouches.length);
+ switch (this.prevPoints.size) {
case 1:
this.handle1PointerDown(e);
break;
@@ -67,35 +68,29 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
if (this.prevPoints.has(pt.identifier)) {
this.prevPoints.set(pt.identifier, pt);
}
- else {
- this.prevPoints.set(pt.identifier, pt);
- }
}
}
}
@action
protected onTouchEnd = (e: TouchEvent): void => {
- console.log(InteractionUtils.GetMyTargetTouches(e, this.prevPoints).length + " up");
- this._touchDrag = false;
- e.stopPropagation();
-
+ // console.log(InteractionUtils.GetMyTargetTouches(e, this.prevPoints).length + " up");
// remove all the touches associated with the event
- for (let i = 0; i < e.targetTouches.length; i++) {
- let pt = e.targetTouches.item(i);
- if (pt) {
- if (this.prevPoints.has(pt.identifier)) {
- console.log("delete");
- this.prevPoints.delete(pt.identifier);
- }
+ for (let i = 0; i < e.changedTouches.length; i++) {
+ let pt = e.changedTouches.item(i);
+ if (pt && this.prevPoints.has(pt.identifier)) {
+ this.prevPoints.delete(pt.identifier);
}
}
+ this._touchDrag = false;
+ e.stopPropagation();
- if (e.targetTouches.length === 0) {
- this.prevPoints.clear();
- }
- if (this.prevPoints.size === 0 && e.targetTouches.length === 0) {
+ // if (e.targetTouches.length === 0) {
+ // this.prevPoints.clear();
+ // }
+
+ if (this.prevPoints.size === 0) {
this.cleanUpInteractions();
}
}
diff --git a/src/pen-gestures/GestureUtils.ts b/src/pen-gestures/GestureUtils.ts
index caaa0736d..7a14452c8 100644
--- a/src/pen-gestures/GestureUtils.ts
+++ b/src/pen-gestures/GestureUtils.ts
@@ -6,15 +6,15 @@ import { Doc } from "../new_fields/Doc";
export namespace GestureUtils {
namespace GestureDataTypes {
- export type BoxData = Doc[];
+ export type BoxData = Array<Doc>;
}
- export const GestureRecognizer = new NDollarRecognizer(false);
-
export enum Gestures {
Box = "box"
}
+ export const GestureRecognizer = new NDollarRecognizer(false);
+
export function GestureOptions(name: Gestures, gestureData: any): (() => any)[] {
switch (name) {
case Gestures.Box:
@@ -27,7 +27,7 @@ export namespace GestureUtils {
}
function BoxOptions(gestureData: GestureDataTypes.BoxData): (() => any)[] {
- if (gestureData instanceof Doc[]) {
+ if (gestureData instanceof Array) {
return [() => Docs.Create.FreeformDocument(gestureData as Doc[], {})];
}
return [];