aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index b87980397..6699aa133 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -677,7 +677,22 @@ export function StopEvent(e: React.PointerEvent | React.MouseEvent) {
e.preventDefault();
}
+/**
+ * Helper method for converting pixel string eg. '32px' into number eg. 32
+ * @param value: string with 'px' ending
+ * @returns value: number
+ *
+ * Example:
+ * '32px' -> 32
+ */
+export function numberValue(value: string | undefined):number {
+ if (value == undefined) return 0;
+ return parseInt(value);
+}
+export function numbersAlmostEqual(num1: number, num2: number) {
+ return Math.abs( num1 - num2 ) < 0.2;
+}
export function setupMoveUpEvents(
target: object,