Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom resize handle #79

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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