diff --git a/lib/Resizable.js b/lib/Resizable.js index a2eede3d..f6d87839 100644 --- a/lib/Resizable.js +++ b/lib/Resizable.js @@ -126,8 +126,11 @@ export default class Resizable extends React.Component { if (axisV === 'n') deltaY = -deltaY; // Update w/h by the deltas. Also factor in transformScale. - let width = this.props.width + (canDragX ? deltaX / this.props.transformScale : 0); - let height = this.props.height + (canDragY ? deltaY / this.props.transformScale : 0); + const transformScale = this.props.transformScale; + const transformScaleW = typeof transformScale === 'number' ? transformScale : transformScale.w; + const transformScaleH = typeof transformScale === 'number' ? transformScale : transformScale.h; + let width = this.props.width + (canDragX ? deltaX / transformScaleW : 0); + let height = this.props.height + (canDragY ? deltaY / transformScaleH : 0); // Run user-provided constraints. [width, height] = this.runConstraints(width, height); diff --git a/lib/propTypes.js b/lib/propTypes.js index 9b344a0e..d2c1e586 100644 --- a/lib/propTypes.js +++ b/lib/propTypes.js @@ -34,7 +34,7 @@ export type DefaultProps = { minConstraints: [number, number], maxConstraints: [number, number], resizeHandles: ResizeHandleAxis[], - transformScale: number, + transformScale: number | { w: number; h: number }, }; export type Props = { @@ -137,7 +137,13 @@ export const resizableProps: Object = { /* * If `transform: scale(n)` is set on the parent, this should be set to `n`. * */ - transformScale: PropTypes.number, + transformScale: PropTypes.oneOfType([ + PropTypes.number, + PropTypes.shape({ + w: PropTypes.number, + h: PropTypes.number + }) + ]), /* * Initial width */