Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="react-konva DEMO">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>react-konva DEMO</title>
  <script type="text/javascript" src="https://rawgit.com/konvajs/konva/master/konva.js"></script>
  <script type="text/javascript" src="https://rawgit.com/lavrton/react-konva/master/dist/react-konva.bundle.js"></script>
</head>
<body>
  <div id='container'></div>
</body>
</html>
 
const {Layer, Rect, Stage, Group} = ReactKonva;
// try drag& drop rectangle
class MyRect extends React.Component {
    changeSize() {
        this.refs.rect.to({
            scaleX: Math.random() + 0.8,
            scaleY: Math.random() + 0.8,
            duration: 0.2
        });
    }
    render() {
        return (
            <Group>
                <Rect
                    ref="rect"
                    width="50"
                    height="50"
                    fill="green"
                    draggable="true"
                    onDragEnd={this.changeSize.bind(this)}
                    onDragStart={this.changeSize.bind(this)}
                />
          </Group>
        );
    }
}
function App() {
    return (
      <Stage width={700} height={700}>
        <Layer>
            <MyRect/>
        </Layer>
      </Stage>
    );
}
ReactDOM.render(<App/>, document.getElementById('container'));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
lavrtonpro
0viewers