Skip to content

Commit e2ffd08

Browse files
committed
Merge branch 'storybook' of https://github.com/aeagle/react-spaces into storybook
2 parents 2fb3046 + 0a86610 commit e2ffd08

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ yarn-debug.log*
2222
yarn-error.log*
2323
**/.rpt2_cache
2424
**/.next
25+
**/storybook-static

src/components/ResizeHandle.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ interface IProps {
88
resizable?: boolean;
99
anchor?: AnchorType;
1010
handleSize?: number;
11+
maximumSize?: number;
12+
minimumSize?: number;
1113
parentContext: ISpaceContext | undefined;
1214
space: ISpace;
1315
spaceElement: HTMLElement | undefined;

src/components/Space.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export const SpaceInternal: React.FC<AllProps> = React.memo((props) => {
143143
parentContext={parentContext}
144144
space={space}
145145
spaceElement={spaceElement.current}
146+
minimumSize={props.minimumSize}
147+
maximumSize={props.maximumSize}
146148
/>
147149
<div className={innerClasses.join(" ")} style={innerStyle}>
148150
<SpaceContext.Provider value={currentContext}>
@@ -172,6 +174,8 @@ export const SpaceInternal: React.FC<AllProps> = React.memo((props) => {
172174
parentContext={parentContext}
173175
space={space}
174176
spaceElement={spaceElement.current}
177+
minimumSize={props.minimumSize}
178+
maximumSize={props.maximumSize}
175179
/>
176180
<SpaceContext.Provider value={currentContext}>
177181
<SpaceInfoContext.Provider value={{ width: Math.floor(currentSize.width), height: Math.floor(currentSize.height) }}>

src/resizing.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ResizeType, AllProps, AnchorToResizeTypeMap, ISpace, IPosition } from "./types";
2-
import { isHorizontalSpace } from "./utils";
2+
import { isHorizontalSpace, coalesce } from "./utils";
33
import { ISpaceContext, updateSpace } from "./ISpaceContext";
44
import { throttle } from "./throttle";
55
import { SyntheticEvent } from "react";
@@ -147,8 +147,9 @@ function startResize<T extends SyntheticEvent<HTMLElement> | MouseEvent | TouchE
147147
const coords = getCoords(e);
148148
const originalMouseX = resizeType === ResizeType.Left ? coords.x + space.adjustedSize : coords.x - space.adjustedSize;
149149
const originalMouseY = resizeType === ResizeType.Top ? coords.y + space.adjustedSize : coords.y - space.adjustedSize;
150-
const minimumAdjust = (props.minimumSize === undefined ? 20 : props.minimumSize) - size + space.adjustedSize;
150+
const minimumAdjust = coalesce(props.minimumSize, 20) - size + space.adjustedSize;
151151
const maximumAdjust = props.maximumSize ? props.maximumSize - size + space.adjustedSize : undefined;
152+
152153
let lastX = 0;
153154
let lastY = 0;
154155
let moved = false;

0 commit comments

Comments
 (0)