Skip to content
Closed
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
13 changes: 11 additions & 2 deletions lib/Resizable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ export default class Resizable extends React.Component {
return [width, height];
}

getBodyScale() {
const regExp = /scale\(([^)]+)\)/;
const bodyTransform = document && document.body ? document.body.style.transform : '';
const matches = regExp.exec(bodyTransform);
return matches ? matches[1] : 1;
}

/**
* Wrapper around drag events to provide more useful data.
*
Expand All @@ -166,9 +173,11 @@ export default class Resizable extends React.Component {
const canDragX = this.props.axis === 'both' || this.props.axis === 'x';
const canDragY = this.props.axis === 'both' || this.props.axis === 'y';

const scale = this.getBodyScale();

// Update w/h
let width = this.state.width + (canDragX ? deltaX : 0);
let height = this.state.height + (canDragY ? deltaY : 0);
let width = this.state.width + (canDragX ? deltaX / scale : 0);
let height = this.state.height + (canDragY ? deltaY / scale : 0);

// Early return if no change
const widthChanged = width !== this.state.width, heightChanged = height !== this.state.height;
Expand Down