Skip to content

Commit

Permalink
Merge pull request #79 from cheton/master
Browse files Browse the repository at this point in the history
Custom resize handle
  • Loading branch information
STRML authored Apr 3, 2019
2 parents 74ef3b1 + 5ac56cb commit 2a7f138
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/Resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type Props = {
className?: ?string,
width: number,
height: number,
handle: ReactElement<any>,
handleSize: [number, number],
lockAspectRatio: boolean,
axis: Axis,
Expand Down Expand Up @@ -54,6 +55,9 @@ export default class Resizable extends React.Component<Props, State> {
// Optional props
//

// Custom resize handle
handle: PropTypes.element,

// If you change this, be sure to update your css
handleSize: PropTypes.array,

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

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

Expand All @@ -223,8 +227,8 @@ export default class Resizable extends React.Component<Props, State> {
onStop={this.resizeHandler('onResizeStop')}
onStart={this.resizeHandler('onResizeStart')}
onDrag={this.resizeHandler('onResize')}
>
<span className="react-resizable-handle" />
>
{handle || <span className="react-resizable-handle" />}
</DraggableCore>
]
});
Expand Down
5 changes: 3 additions & 2 deletions lib/ResizableBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
// Basic wrapper around a Resizable instance.
// If you use Resizable directly, you are responsible for updating the child component
// with a new width and height.
const {handleSize, onResize, onResizeStart, onResizeStop, draggableOpts,
const {handle, handleSize, onResize, onResizeStart, onResizeStop, draggableOpts,
minConstraints, maxConstraints, lockAspectRatio, axis, width, height, ...props} = this.props;
return (
<Resizable
handle={handle}
handleSize={handleSize}
width={this.state.width}
height={this.state.height}
Expand All @@ -63,7 +64,7 @@ export default class ResizableBox extends React.Component<ResizableProps, State>
maxConstraints={maxConstraints}
lockAspectRatio={lockAspectRatio}
axis={axis}
>
>
<div style={{width: this.state.width + 'px', height: this.state.height + 'px'}} {...props} />
</Resizable>
);
Expand Down

0 comments on commit 2a7f138

Please sign in to comment.