From c5d7f107d79a4aa5bba952fcd07c0351edc16654 Mon Sep 17 00:00:00 2001 From: moklick Date: Tue, 9 Jan 2024 16:49:15 +0100 Subject: [PATCH] refactor(resizer): correct typo --- .../NodeResizer/NodeResizeControl.tsx | 2 +- .../lib/plugins/NodeResizer/ResizeControl.svelte | 2 +- packages/system/src/xyresizer/XYResizer.ts | 10 +++++----- packages/system/src/xyresizer/utils.ts | 13 +++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/react/src/additional-components/NodeResizer/NodeResizeControl.tsx b/packages/react/src/additional-components/NodeResizer/NodeResizeControl.tsx index b1098ed1..2f16f150 100644 --- a/packages/react/src/additional-components/NodeResizer/NodeResizeControl.tsx +++ b/packages/react/src/additional-components/NodeResizer/NodeResizeControl.tsx @@ -98,7 +98,7 @@ function ResizeControl({ resizer.current.update({ controlPosition, - boundries: { + boundaries: { minWidth, minHeight, maxWidth, diff --git a/packages/svelte/src/lib/plugins/NodeResizer/ResizeControl.svelte b/packages/svelte/src/lib/plugins/NodeResizer/ResizeControl.svelte index da4df10c..4688b4e7 100644 --- a/packages/svelte/src/lib/plugins/NodeResizer/ResizeControl.svelte +++ b/packages/svelte/src/lib/plugins/NodeResizer/ResizeControl.svelte @@ -89,7 +89,7 @@ $: { resizer?.update({ controlPosition, - boundries: { + boundaries: { minWidth: _minWidth, minHeight: _minHeight, maxWidth: _maxWidth, diff --git a/packages/system/src/xyresizer/XYResizer.ts b/packages/system/src/xyresizer/XYResizer.ts index 75f59706..63f146d5 100644 --- a/packages/system/src/xyresizer/XYResizer.ts +++ b/packages/system/src/xyresizer/XYResizer.ts @@ -1,10 +1,10 @@ import { drag } from 'd3-drag'; import { select } from 'd3-selection'; -import { NodeLookup, Transform } from '../types'; -import { OnResize, OnResizeEnd, OnResizeStart, ResizeDragEvent, ShouldResize, ControlPosition } from './types'; import { getControlDirection, getDimensionsAfterResize, getPositionAfterResize, getResizeDirection } from './utils'; import { getPointerPosition } from '../utils'; +import type { NodeLookup, Transform } from '../types'; +import type { OnResize, OnResizeEnd, OnResizeStart, ResizeDragEvent, ShouldResize, ControlPosition } from './types'; const initPrevValues = { width: 0, height: 0, x: 0, y: 0 }; @@ -43,7 +43,7 @@ type XYResizerParams = { type XYResizerUpdateParams = { controlPosition: ControlPosition; - boundries: { + boundaries: { minWidth: number; minHeight: number; maxWidth: number; @@ -66,7 +66,7 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize function update({ controlPosition, - boundries, + boundaries, keepAspectRatio, onResizeStart, onResize, @@ -114,7 +114,7 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize startValues, controlDirection, pointerPosition, - boundries, + boundaries, keepAspectRatio ); diff --git a/packages/system/src/xyresizer/utils.ts b/packages/system/src/xyresizer/utils.ts index cd98e593..0d7d8a9e 100644 --- a/packages/system/src/xyresizer/utils.ts +++ b/packages/system/src/xyresizer/utils.ts @@ -80,7 +80,7 @@ type StartValues = PrevValues & { * @param startValues - starting values of resize * @param controlDirection - dimensions affected by the resize * @param pointerPosition - the current pointer position corrected for snapping - * @param boundries - maximum and minimum dimensions of the node + * @param boundaries - minimum and maximum dimensions of the node * @param keepAspectRatio - prevent changes of asprect ratio * @returns width: new width of node, height: new height of node */ @@ -88,12 +88,12 @@ export function getDimensionsAfterResize( startValues: StartValues, controlDirection: ReturnType, pointerPosition: ReturnType, - boundries: { minWidth: number; maxWidth: number; minHeight: number; maxHeight: number }, + boundaries: { minWidth: number; maxWidth: number; minHeight: number; maxHeight: number }, keepAspectRatio: boolean ) { const { isHorizontal, isVertical, affectsX, affectsY } = controlDirection; const { xSnapped, ySnapped } = pointerPosition; - const { minWidth, maxWidth, minHeight, maxHeight } = boundries; + const { minWidth, maxWidth, minHeight, maxHeight } = boundaries; const { pointerX: startX, pointerY: startY, width: startWidth, height: startHeight, aspectRatio } = startValues; const distX = Math.floor(isHorizontal ? xSnapped - startX : 0); @@ -148,7 +148,8 @@ export function getPositionAfterResize( width: number, height: number ) { - const x = controlDirection.affectsX ? startValues.x - (width - startValues.width) : startValues.x; - const y = controlDirection.affectsY ? startValues.y - (height - startValues.height) : startValues.y; - return { x, y }; + return { + x: controlDirection.affectsX ? startValues.x - (width - startValues.width) : startValues.x, + y: controlDirection.affectsY ? startValues.y - (height - startValues.height) : startValues.y, + }; }