From 953e9dacf886aa5dff7331ca1f7ba7ba7f5373dd Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 23 Feb 2021 21:46:57 -0500
Subject: cleaned up viewTransitions in CollectionFreeFormView to not write to
 document for transient effects.

---
 src/client/views/Touchable.tsx | 39 ++++++++-------------------------------
 1 file changed, 8 insertions(+), 31 deletions(-)

(limited to 'src/client/views/Touchable.tsx')

diff --git a/src/client/views/Touchable.tsx b/src/client/views/Touchable.tsx
index bb9e108cb..789756a78 100644
--- a/src/client/views/Touchable.tsx
+++ b/src/client/views/Touchable.tsx
@@ -11,7 +11,6 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
     private holdMoveDisposer?: InteractionUtils.MultiTouchEventDisposer;
     private holdEndDisposer?: InteractionUtils.MultiTouchEventDisposer;
 
-
     protected abstract _multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
     protected _touchDrag: boolean = false;
     protected prevPoints: Map<number, React.Touch> = new Map<number, React.Touch>();
@@ -86,19 +85,13 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
         if (!InteractionUtils.IsDragging(this.prevPoints, myTouches, 5) && !this._touchDrag) return;
         this._touchDrag = true;
         switch (myTouches.length) {
-            case 1:
-                this.handle1PointerMove(te, me);
-                break;
-            case 2:
-                this.handle2PointersMove(te, me);
-                break;
+            case 1: this.handle1PointerMove(te, me); break;
+            case 2: this.handle2PointersMove(te, me); break;
         }
 
         for (const pt of me.touches) {
-            if (pt) {
-                if (this.prevPoints.has(pt.identifier)) {
-                    this.prevPoints.set(pt.identifier, pt);
-                }
+            if (pt && this.prevPoints.has(pt.identifier)) {
+                this.prevPoints.set(pt.identifier, pt);
             }
         }
     }
@@ -166,7 +159,6 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
         this.removeHoldEndListeners();
         this.addHoldMoveListeners();
         this.addHoldEndListeners();
-
     }
 
     addMoveListeners = () => {
@@ -174,21 +166,12 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
         document.addEventListener("dashOnTouchMove", handler);
         this.moveDisposer = () => document.removeEventListener("dashOnTouchMove", handler);
     }
-
-    removeMoveListeners = () => {
-        this.moveDisposer && this.moveDisposer();
-    }
-
     addEndListeners = () => {
         const handler = (e: Event) => this.onTouchEnd(e, (e as CustomEvent<InteractionUtils.MultiTouchEvent<TouchEvent>>).detail);
         document.addEventListener("dashOnTouchEnd", handler);
         this.endDisposer = () => document.removeEventListener("dashOnTouchEnd", handler);
     }
 
-    removeEndListeners = () => {
-        this.endDisposer && this.endDisposer();
-    }
-
     addHoldMoveListeners = () => {
         const handler = (e: Event) => this.handle1PointerHoldMove(e, (e as CustomEvent<InteractionUtils.MultiTouchEvent<TouchEvent>>).detail);
         document.addEventListener("dashOnTouchHoldMove", handler);
@@ -201,21 +184,16 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
         this.holdEndDisposer = () => document.removeEventListener("dashOnTouchHoldEnd", handler);
     }
 
-    removeHoldMoveListeners = () => {
-        this.holdMoveDisposer && this.holdMoveDisposer();
-    }
-
-    removeHoldEndListeners = () => {
-        this.holdEndDisposer && this.holdEndDisposer();
-    }
-
+    removeMoveListeners = () => this.moveDisposer?.();
+    removeEndListeners = () => this.endDisposer?.();
+    removeHoldMoveListeners = () => this.holdMoveDisposer?.();
+    removeHoldEndListeners = () => this.holdEndDisposer?.();
 
     handle1PointerHoldMove = (e: Event, me: InteractionUtils.MultiTouchEvent<TouchEvent>): void => {
         // e.stopPropagation();
         // me.touchEvent.stopPropagation();
     }
 
-
     handle1PointerHoldEnd = (e: Event, me: InteractionUtils.MultiTouchEvent<TouchEvent>): void => {
         e.stopPropagation();
         me.touchEvent.stopPropagation();
@@ -226,7 +204,6 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
         me.touchEvent.preventDefault();
     }
 
-
     handleHandDown = (e: React.TouchEvent) => {
         // e.stopPropagation();
         // e.preventDefault();
-- 
cgit v1.2.3-70-g09d2

