Skip to content

Commit 5ac56cb

Browse files
committed
Custom resize handle
1 parent cd25ce6 commit 5ac56cb

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/Resizable.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type Props = {
2626
className?: ?string,
2727
width: number,
2828
height: number,
29+
handle: ReactElement<any>,
2930
handleSize: [number, number],
3031
lockAspectRatio: boolean,
3132
axis: Axis,
@@ -54,6 +55,9 @@ export default class Resizable extends React.Component<Props, State> {
5455
// Optional props
5556
//
5657

58+
// Custom resize handle
59+
handle: PropTypes.element,
60+
5761
// If you change this, be sure to update your css
5862
handleSize: PropTypes.array,
5963

@@ -200,7 +204,7 @@ export default class Resizable extends React.Component<Props, State> {
200204

201205
render(): ReactNode {
202206
// eslint-disable-next-line no-unused-vars
203-
const {children, draggableOpts, width, height, handleSize,
207+
const {children, draggableOpts, width, height, handle, handleSize,
204208
lockAspectRatio, axis, minConstraints, maxConstraints, onResize,
205209
onResizeStop, onResizeStart, ...p} = this.props;
206210

@@ -223,8 +227,8 @@ export default class Resizable extends React.Component<Props, State> {
223227
onStop={this.resizeHandler('onResizeStop')}
224228
onStart={this.resizeHandler('onResizeStart')}
225229
onDrag={this.resizeHandler('onResize')}
226-
>
227-
<span className="react-resizable-handle" />
230+
>
231+
{handle || <span className="react-resizable-handle" />}
228232
</DraggableCore>
229233
]
230234
});

lib/ResizableBox.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
4848
// Basic wrapper around a Resizable instance.
4949
// If you use Resizable directly, you are responsible for updating the child component
5050
// with a new width and height.
51-
const {handleSize, onResize, onResizeStart, onResizeStop, draggableOpts,
51+
const {handle, handleSize, onResize, onResizeStart, onResizeStop, draggableOpts,
5252
minConstraints, maxConstraints, lockAspectRatio, axis, width, height, ...props} = this.props;
5353
return (
5454
<Resizable
55+
handle={handle}
5556
handleSize={handleSize}
5657
width={this.state.width}
5758
height={this.state.height}
@@ -63,7 +64,7 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
6364
maxConstraints={maxConstraints}
6465
lockAspectRatio={lockAspectRatio}
6566
axis={axis}
66-
>
67+
>
6768
<div style={{width: this.state.width + 'px', height: this.state.height + 'px'}} {...props} />
6869
</Resizable>
6970
);

0 commit comments

Comments
 (0)