1
1
import React , { Component } from 'react'
2
- import ReactDOM from 'react-dom'
3
- import ResizableRect from './ResizableRect '
2
+
3
+ import Resizer from 'react-resizable-rotatable-draggable '
4
4
import styled from 'styled-components'
5
5
6
6
const RootDiv = styled . div `
7
- text-align: center;
7
+ text-align: center;
8
8
`
9
9
10
- class AppExample extends Component {
10
+ export default class App extends Component {
11
11
constructor ( ) {
12
12
super ( )
13
13
this . state = {
@@ -19,24 +19,17 @@ class AppExample extends Component {
19
19
}
20
20
}
21
21
22
- handleResize = ( style , isShiftKey , type ) => {
23
- let { top, left, width, height } = style
24
- top = Math . round ( top )
25
- left = Math . round ( left )
26
- width = Math . round ( width )
27
- height = Math . round ( height )
22
+ handleResize = ( { top, left, width, height } , isShiftKey , type ) => {
28
23
this . setState ( {
29
- top,
30
- left,
31
- width,
32
- height
24
+ top : Math . round ( top ) ,
25
+ left : Math . round ( left ) ,
26
+ width : Math . round ( width ) ,
27
+ height : Math . round ( height )
33
28
} )
34
29
}
35
30
36
31
handleRotate = ( rotateAngle ) => {
37
- this . setState ( {
38
- rotateAngle
39
- } )
32
+ this . setState ( { rotateAngle } )
40
33
}
41
34
42
35
handleDrag = ( deltaX , deltaY ) => {
@@ -47,14 +40,21 @@ class AppExample extends Component {
47
40
}
48
41
49
42
handleRotateEnd = ( ) => console . log ( 'aa' )
50
- handleRotateStart = ( ) => console . log ( "start" )
43
+
44
+ handleRotateStart = ( ) => console . log ( 'start' )
45
+
51
46
render ( ) {
52
47
const { width, top, left, height, rotateAngle } = this . state
53
48
54
49
return (
55
50
< RootDiv className = "App" >
56
- < ResizableRect
57
- { ...{ left, top, width, height, rotateAngle } }
51
+ < Resizer
52
+ top = { top }
53
+ left = { left }
54
+ width = { width }
55
+ height = { height }
56
+ rotateAngle = { rotateAngle }
57
+
58
58
// aspectRatio={false}
59
59
minWidth = { - Infinity }
60
60
minHeight = { - Infinity }
@@ -74,7 +74,3 @@ handleRotateStart = () => console.log("start")
74
74
)
75
75
}
76
76
}
77
-
78
- const init = ( element ) => { ReactDOM . render ( < AppExample /> , element ) }
79
-
80
- export { init }
0 commit comments