diff options
| author | Andy Rickert <andrew_rickert@brown.edu> | 2020-05-12 17:37:54 -0700 | 
|---|---|---|
| committer | Andy Rickert <andrew_rickert@brown.edu> | 2020-05-12 17:37:54 -0700 | 
| commit | 9ad062907d38a7a853ba89fa31433380ae3cd7b3 (patch) | |
| tree | 707855e1bc6fa8ac3d1f51447815a51eb83b8aa3 /src/Utils.ts | |
| parent | 1848c78f889470d6c558f709efe1b521402b2793 (diff) | |
| parent | 4bd011dcc6a3f009fa10932c7c6ca1932b784fde (diff) | |
merge
Diffstat (limited to 'src/Utils.ts')
| -rw-r--r-- | src/Utils.ts | 12 | 
1 files changed, 8 insertions, 4 deletions
| diff --git a/src/Utils.ts b/src/Utils.ts index ad12c68a1..bcb215804 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -4,7 +4,7 @@ import { Socket, Room } from 'socket.io';  import { Message } from './server/Message';  export namespace Utils { -    export const DRAG_THRESHOLD = 4; +    export let DRAG_THRESHOLD = 4;      export function GenerateGuid(): string {          return v4(); @@ -313,14 +313,18 @@ export namespace Utils {      }  } -export function OmitKeys(obj: any, keys: string[], addKeyFunc?: (dup: any) => void): { omit: any, extract: any } { +export function OmitKeys(obj: any, keys: string[], pattern?: string, addKeyFunc?: (dup: any) => void): { omit: any, extract: any } {      const omit: any = { ...obj };      const extract: any = {};      keys.forEach(key => {          extract[key] = omit[key];          delete omit[key];      }); -    addKeyFunc && addKeyFunc(omit); +    pattern && Array.from(Object.keys(omit)).filter(key => key.match(pattern)).forEach(key => { +        extract[key] = omit[key]; +        delete omit[key]; +    }); +    addKeyFunc?.(omit);      return { omit, extract };  } @@ -512,7 +516,7 @@ export function setupMoveUpEvents(      (target as any)._downY = (target as any)._lastY = e.clientY;      const _moveEvent = (e: PointerEvent): void => { -        if (Math.abs(e.clientX - (target as any)._downX) > 4 || Math.abs(e.clientY - (target as any)._downY) > 4) { +        if (Math.abs(e.clientX - (target as any)._downX) > Utils.DRAG_THRESHOLD || Math.abs(e.clientY - (target as any)._downY) > Utils.DRAG_THRESHOLD) {              if (moveEvent(e, [(target as any)._downX, (target as any)._downY],                  [e.clientX - (target as any)._lastX, e.clientY - (target as any)._lastY])) {                  document.removeEventListener("pointermove", _moveEvent); | 
