aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index b5c218e01..e8bd35ac4 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -7,6 +7,7 @@ import { Socket } from '../node_modules/socket.io/dist/index';
import { DocumentType } from './client/documents/DocumentTypes';
import { Colors } from './client/views/global/globalEnums';
import { Message } from './server/Message';
+import { DocumentView } from './client/views/nodes/DocumentView';
export namespace Utils {
export let CLICK_TIME = 300;
@@ -513,6 +514,10 @@ export function intersectRect(r1: { left: number; top: number; width: number; he
return !(r2.left > r1.left + r1.width || r2.left + r2.width < r1.left || r2.top > r1.top + r1.height || r2.top + r2.height < r1.top);
}
+export function stringHash(s?: string) {
+ return !s ? undefined : Math.abs(s.split('').reduce((a: any, b: any) => (a => a & a)((a << 5) - a + b.charCodeAt(0)), 0));
+}
+
export function percent2frac(percent: string) {
return Number(percent.substr(0, percent.length - 1)) / 100;
}
@@ -583,7 +588,7 @@ export function returnEmptyDoclist() {
return [] as any[];
}
-export let emptyPath = [];
+export let emptyPath: DocumentView[] = [];
export function emptyFunction() {
return undefined;
@@ -847,9 +852,11 @@ export function setupMoveUpEvents(
(target as any)._downX = (target as any)._lastX = e.clientX;
(target as any)._downY = (target as any)._lastY = e.clientY;
(target as any)._noClick = false;
+ var moving = false;
const _moveEvent = (e: PointerEvent): void => {
- if (Math.abs(e.clientX - (target as any)._downX) > Utils.DRAG_THRESHOLD || Math.abs(e.clientY - (target as any)._downY) > Utils.DRAG_THRESHOLD) {
+ if (moving || Math.abs(e.clientX - (target as any)._downX) > Utils.DRAG_THRESHOLD || Math.abs(e.clientY - (target as any)._downY) > Utils.DRAG_THRESHOLD) {
+ moving = true;
if ((target as any)._doubleTime) {
clearTimeout((target as any)._doubleTime);
(target as any)._doubleTime = undefined;