1
- import React , { Component , createRef , Fragment } from " react" ;
1
+ import React , { Component , createRef , Fragment } from ' react' ;
2
2
// import PropTypes from 'prop-types';
3
- import { Stage , Layer , Group , Label , Text } from "react-konva" ;
4
- import TransformerComponent from "./TransformerComponent.jsx" ;
5
- import Rectangle from "./Rectangle.jsx" ;
3
+ import {
4
+ Stage , Layer , Group , Label , Text ,
5
+ } from 'react-konva' ;
6
+ import TransformerComponent from './TransformerComponent.jsx' ;
7
+ import Rectangle from './Rectangle.jsx' ;
6
8
7
9
class KonvaStage extends Component {
8
10
state = {
9
11
x : undefined ,
10
- y : undefined
12
+ y : undefined ,
11
13
} ;
12
14
13
15
constructor ( props ) {
@@ -16,22 +18,21 @@ class KonvaStage extends Component {
16
18
this . group = createRef ( ) ;
17
19
}
18
20
19
- handleStageMouseDown = e => {
21
+ handleStageMouseDown = ( e ) => {
20
22
// // clicked on stage - clear selection
21
23
if ( e . target === e . target . getStage ( ) ) {
22
24
// add functionality for allowing no focusChild
23
25
return ;
24
26
}
25
27
// // clicked on transformer - do nothing
26
- const clickedOnTransformer =
27
- e . target . getParent ( ) . className === "Transformer" ;
28
+ const clickedOnTransformer = e . target . getParent ( ) . className === 'Transformer' ;
28
29
if ( clickedOnTransformer ) {
29
30
return ;
30
31
}
31
32
32
33
// find clicked rect by its name
33
34
const rectChildId = e . target . attrs . childId ;
34
- console . log ( " e.target : " , rectChildId ) ;
35
+ console . log ( ' e.target : ' , rectChildId ) ;
35
36
this . props . changeFocusChild ( { childId : rectChildId } ) ;
36
37
} ;
37
38
@@ -49,13 +50,13 @@ class KonvaStage extends Component {
49
50
scaleY,
50
51
focusComponent,
51
52
focusChild,
52
- changeFocusChild
53
+ changeFocusChild,
53
54
} = this . props ;
54
55
const { selectedShapeName } = this . state ;
55
56
56
57
return (
57
58
< Stage
58
- ref = { node => {
59
+ ref = { ( node ) => {
59
60
this . stage = node ;
60
61
} }
61
62
onMouseDown = { this . handleStageMouseDown }
0 commit comments