Skip to content

Commit 81155f6

Browse files
committed
ADD: parentAngle v0.1.4
1 parent c76e3ce commit 81155f6

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-resizable-rotatable-draggable",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "A rectangle react component which can be resized and rotated",
55
"author": "MockingBot",
66
"license": "MIT",

src/ResizableRect.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class ResizableRect extends Component {
3535
height: PropTypes.number.isRequired,
3636
rotatable: PropTypes.bool,
3737
rotateAngle: PropTypes.number,
38+
parentRotateAngle: PropTypes.number,
3839
zoomable: PropTypes.string,
3940
minWidth: PropTypes.number,
4041
minHeight: PropTypes.number,
@@ -53,6 +54,7 @@ class ResizableRect extends Component {
5354
onDragEnd: PropTypes.func
5455
}
5556
static defaultProps = {
57+
parentRotateAngle: 0,
5658
rotateAngle: 0,
5759
rotatable: true,
5860
zoomable: '',
@@ -82,8 +84,8 @@ class ResizableRect extends Component {
8284

8385
handleResize = (length, alpha, rect, type, isShiftKey) => {
8486
if (!this.props.onResize) return
85-
const { rotateAngle, aspectRatio, minWidth, minHeight } = this.props
86-
const beta = alpha - degToRadian(rotateAngle)
87+
const { rotateAngle, aspectRatio, minWidth, minHeight, parentRotateAngle } = this.props
88+
const beta = alpha - degToRadian(rotateAngle + parentRotateAngle)
8789
const deltaW = length * Math.cos(beta)
8890
const deltaH = length * Math.sin(beta)
8991
const ratio = isShiftKey && !aspectRatio ? rect.width / rect.height : aspectRatio

0 commit comments

Comments
 (0)