aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaafiyan Ahmed <naafiyan@gmail.com>2022-04-14 17:46:15 -0400
committerNaafiyan Ahmed <naafiyan@gmail.com>2022-04-14 17:46:15 -0400
commit605ab32150c5b2b9d84eb817d3086796b72964df (patch)
tree233ec4648f8b96bf3a8feffa48b7ba7ad31d5b7b /src
parent4209154f5b430af481a99982fb86c2ef1bd1ccd1 (diff)
fix: fixed panning with finger interaction
Diffstat (limited to 'src')
-rw-r--r--src/client/util/InteractionUtils.tsx2
-rw-r--r--src/client/views/GestureOverlay.tsx13
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
3 files changed, 11 insertions, 6 deletions
diff --git a/src/client/util/InteractionUtils.tsx b/src/client/util/InteractionUtils.tsx
index 3e051dec8..675dff00b 100644
--- a/src/client/util/InteractionUtils.tsx
+++ b/src/client/util/InteractionUtils.tsx
@@ -286,6 +286,8 @@ export namespace InteractionUtils {
// pen and eraser are both pointer type 'pen', but pen is button 0 and eraser is button 5. -syip2
case PENTYPE: return e.pointerType === PENTYPE && (e.button === -1 || e.button === 0);
case ERASERTYPE: return e.pointerType === PENTYPE && e.button === (e instanceof PointerEvent ? ERASER_BUTTON : ERASER_BUTTON);
+ case TOUCHTYPE:
+ return e.pointerType === TOUCHTYPE;
default: return e.pointerType === type;
}
}
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index f034e06ad..75a757280 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -85,7 +85,6 @@ export class GestureOverlay extends Touchable {
const ntt: (React.Touch | Touch)[] = Array.from(e.targetTouches);
const nct: (React.Touch | Touch)[] = Array.from(e.changedTouches);
const nt: (React.Touch | Touch)[] = Array.from(e.touches);
- console.log("getNewTouches");
this._hands.forEach((hand) => {
for (let i = 0; i < e.targetTouches.length; i++) {
const pt = e.targetTouches.item(i);
@@ -112,7 +111,6 @@ export class GestureOverlay extends Touchable {
}
onReactTouchStart = (te: React.TouchEvent) => {
- console.log("react touch start");
document.removeEventListener("touchmove", this.onReactHoldTouchMove);
document.removeEventListener("touchend", this.onReactHoldTouchEnd);
if (RadialMenu.Instance?._display === true) {
@@ -131,6 +129,7 @@ export class GestureOverlay extends Touchable {
// pen is also a touch, but with a radius of 0.5 (at least with the surface pens)
// and this seems to be the only way of differentiating pen and touch on touch events
if (pt.radiusX > 1 && pt.radiusY > 1) {
+ Doc.UserDoc().activeInkTool = InkTool.None;
this.prevPoints.set(pt.identifier, pt);
}
}
@@ -209,7 +208,6 @@ export class GestureOverlay extends Touchable {
}
onReactTouchMove = (e: TouchEvent) => {
- console.log("react touch move");
const nts: any = this.getNewTouches(e);
this._holdTimer && clearTimeout(this._holdTimer);
this._holdTimer = undefined;
@@ -500,6 +498,10 @@ export class GestureOverlay extends Touchable {
@action
onPointerDown = (e: React.PointerEvent) => {
+ if (InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) {
+ CurrentUserUtils.SelectedTool = InkTool.None;
+ return;
+ }
if (InteractionUtils.IsType(e, InteractionUtils.PENTYPE) || [InkTool.Highlighter, InkTool.Pen, InkTool.Write].includes(CurrentUserUtils.SelectedTool)) {
if (InteractionUtils.IsType(e, InteractionUtils.PENTYPE)) {
CurrentUserUtils.SelectedTool = InkTool.Write;
@@ -631,7 +633,8 @@ export class GestureOverlay extends Touchable {
}
// if no gesture (or if the gesture was unsuccessful), "dry" the stroke into an ink document
- if (!actionPerformed) {
+ console.log("dispatch gesture", CurrentUserUtils.SelectedTool);
+ if (!actionPerformed && CurrentUserUtils.SelectedTool !== InkTool.None) {
const newPoints = this._points.reduce((p, pts) => { p.push([pts.X, pts.Y]); return p; }, [] as number[][]);
newPoints.pop();
console.log("getting to bezier math");
@@ -650,11 +653,9 @@ export class GestureOverlay extends Touchable {
(controlPoints[0].Y - controlPoints.lastElement().Y) * (controlPoints[0].Y - controlPoints.lastElement().Y));
if (controlPoints.length > 4 && dist < 10) controlPoints[controlPoints.length - 1] = controlPoints[0];
this._points = controlPoints;
-
this.dispatchGesture(GestureUtils.Gestures.Stroke);
// TODO: nda - check inks to group here
checkInksToGroup();
-
}
this._points = [];
this._timeStamps = [];
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 908f08f88..c9465e7a4 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -704,6 +704,8 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
onPointerMove = (e: PointerEvent): void => {
if (InteractionUtils.IsType(e, InteractionUtils.PENTYPE)) return;
if (InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE)) {
+ console.log("is touch");
+ Doc.UserDoc().activeInkTool = InkTool.None;
if (this.props.isContentActive(true)) e.stopPropagation();
} else if (!e.cancelBubble) {
if (this.tryDragCluster(e, this._hitCluster)) {