Skip to content

Commit b23206f

Browse files
Feature/disable resizing (#710)
* add enableResizing false type * code fix * add enableResizing type boolean
1 parent 4e5f2dc commit b23206f

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export type Enable = {
296296
top?: boolean;
297297
topLeft?: boolean;
298298
topRight?: boolean;
299-
}
299+
} | boolean
300300
```
301301

302302
#### `disableDragging?: boolean;`

src/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from "react";
22
import { DraggableEventHandler, default as DraggableRoot } from "react-draggable";
3-
import { Resizable, ResizeDirection } from "re-resizable";
3+
import { Enable, Resizable, ResizeDirection } from "re-resizable";
44

55
// FIXME: https://github.com/mzabriskie/react-draggable/issues/381
66
// I can not find `scale` too...
@@ -80,7 +80,7 @@ export type ResizeEnable = {
8080
top?: boolean;
8181
topLeft?: boolean;
8282
topRight?: boolean;
83-
};
83+
} | boolean;
8484

8585
export type HandleClasses = {
8686
bottom?: string;
@@ -170,6 +170,17 @@ const resizableStyle = {
170170
left: 0,
171171
};
172172

173+
const getEnableResizingByFlag = (flag: boolean): Enable => ({
174+
bottom: flag,
175+
bottomLeft: flag,
176+
bottomRight: flag,
177+
left: flag,
178+
right: flag,
179+
top: flag,
180+
topLeft: flag,
181+
topRight: flag,
182+
});
183+
173184
interface DefaultProps {
174185
maxWidth: number;
175186
maxHeight: number;
@@ -614,7 +625,7 @@ export class Rnd extends React.PureComponent<Props, State> {
614625
ref={this.refResizable}
615626
defaultSize={defaultValue}
616627
size={this.props.size}
617-
enable={enableResizing}
628+
enable={typeof enableResizing === "boolean" ? getEnableResizingByFlag(enableResizing) : enableResizing}
618629
onResizeStart={this.onResizeStart}
619630
onResize={this.onResize}
620631
onResizeStop={this.onResizeStop}

0 commit comments

Comments
 (0)