refactor(resizer): correct typo
This commit is contained in:
@@ -98,7 +98,7 @@ function ResizeControl({
|
|||||||
|
|
||||||
resizer.current.update({
|
resizer.current.update({
|
||||||
controlPosition,
|
controlPosition,
|
||||||
boundries: {
|
boundaries: {
|
||||||
minWidth,
|
minWidth,
|
||||||
minHeight,
|
minHeight,
|
||||||
maxWidth,
|
maxWidth,
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
$: {
|
$: {
|
||||||
resizer?.update({
|
resizer?.update({
|
||||||
controlPosition,
|
controlPosition,
|
||||||
boundries: {
|
boundaries: {
|
||||||
minWidth: _minWidth,
|
minWidth: _minWidth,
|
||||||
minHeight: _minHeight,
|
minHeight: _minHeight,
|
||||||
maxWidth: _maxWidth,
|
maxWidth: _maxWidth,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { drag } from 'd3-drag';
|
import { drag } from 'd3-drag';
|
||||||
import { select } from 'd3-selection';
|
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 { getControlDirection, getDimensionsAfterResize, getPositionAfterResize, getResizeDirection } from './utils';
|
||||||
import { getPointerPosition } 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 };
|
const initPrevValues = { width: 0, height: 0, x: 0, y: 0 };
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ type XYResizerParams = {
|
|||||||
|
|
||||||
type XYResizerUpdateParams = {
|
type XYResizerUpdateParams = {
|
||||||
controlPosition: ControlPosition;
|
controlPosition: ControlPosition;
|
||||||
boundries: {
|
boundaries: {
|
||||||
minWidth: number;
|
minWidth: number;
|
||||||
minHeight: number;
|
minHeight: number;
|
||||||
maxWidth: number;
|
maxWidth: number;
|
||||||
@@ -66,7 +66,7 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize
|
|||||||
|
|
||||||
function update({
|
function update({
|
||||||
controlPosition,
|
controlPosition,
|
||||||
boundries,
|
boundaries,
|
||||||
keepAspectRatio,
|
keepAspectRatio,
|
||||||
onResizeStart,
|
onResizeStart,
|
||||||
onResize,
|
onResize,
|
||||||
@@ -114,7 +114,7 @@ export function XYResizer({ domNode, nodeId, getStoreItems, onChange }: XYResize
|
|||||||
startValues,
|
startValues,
|
||||||
controlDirection,
|
controlDirection,
|
||||||
pointerPosition,
|
pointerPosition,
|
||||||
boundries,
|
boundaries,
|
||||||
keepAspectRatio
|
keepAspectRatio
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ type StartValues = PrevValues & {
|
|||||||
* @param startValues - starting values of resize
|
* @param startValues - starting values of resize
|
||||||
* @param controlDirection - dimensions affected by the resize
|
* @param controlDirection - dimensions affected by the resize
|
||||||
* @param pointerPosition - the current pointer position corrected for snapping
|
* @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
|
* @param keepAspectRatio - prevent changes of asprect ratio
|
||||||
* @returns width: new width of node, height: new height of node
|
* @returns width: new width of node, height: new height of node
|
||||||
*/
|
*/
|
||||||
@@ -88,12 +88,12 @@ export function getDimensionsAfterResize(
|
|||||||
startValues: StartValues,
|
startValues: StartValues,
|
||||||
controlDirection: ReturnType<typeof getControlDirection>,
|
controlDirection: ReturnType<typeof getControlDirection>,
|
||||||
pointerPosition: ReturnType<typeof getPointerPosition>,
|
pointerPosition: ReturnType<typeof getPointerPosition>,
|
||||||
boundries: { minWidth: number; maxWidth: number; minHeight: number; maxHeight: number },
|
boundaries: { minWidth: number; maxWidth: number; minHeight: number; maxHeight: number },
|
||||||
keepAspectRatio: boolean
|
keepAspectRatio: boolean
|
||||||
) {
|
) {
|
||||||
const { isHorizontal, isVertical, affectsX, affectsY } = controlDirection;
|
const { isHorizontal, isVertical, affectsX, affectsY } = controlDirection;
|
||||||
const { xSnapped, ySnapped } = pointerPosition;
|
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 { pointerX: startX, pointerY: startY, width: startWidth, height: startHeight, aspectRatio } = startValues;
|
||||||
const distX = Math.floor(isHorizontal ? xSnapped - startX : 0);
|
const distX = Math.floor(isHorizontal ? xSnapped - startX : 0);
|
||||||
@@ -148,7 +148,8 @@ export function getPositionAfterResize(
|
|||||||
width: number,
|
width: number,
|
||||||
height: number
|
height: number
|
||||||
) {
|
) {
|
||||||
const x = controlDirection.affectsX ? startValues.x - (width - startValues.width) : startValues.x;
|
return {
|
||||||
const y = controlDirection.affectsY ? startValues.y - (height - startValues.height) : startValues.y;
|
x: controlDirection.affectsX ? startValues.x - (width - startValues.width) : startValues.x,
|
||||||
return { x, y };
|
y: controlDirection.affectsY ? startValues.y - (height - startValues.height) : startValues.y,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user