diff --git a/src/actions/workspaceActions.js b/src/actions/workspaceActions.js index 7b0d063..006d15f 100644 --- a/src/actions/workspaceActions.js +++ b/src/actions/workspaceActions.js @@ -22,7 +22,6 @@ export const onChangeWorkspace = (event) => (dispatch, getState) => { type: NEW_CODE, payload: code }); - console.log(event.type); var stats = getState().workspace.stats; if (event.type === Blockly.Events.BLOCK_CREATE){ stats.create += event.ids.length; diff --git a/src/components/Blockly/BlocklyWindow.js b/src/components/Blockly/BlocklyWindow.js index c2fbc70..8ad7486 100644 --- a/src/components/Blockly/BlocklyWindow.js +++ b/src/components/Blockly/BlocklyWindow.js @@ -20,6 +20,7 @@ class BlocklyWindow extends Component { componentDidMount() { const workspace = Blockly.getMainWorkspace(); + this.props.onChangeWorkspace({}); workspace.addChangeListener((event) => { this.props.onChangeWorkspace(event); }); diff --git a/src/components/Home.js b/src/components/Home.js index 8638b6d..47823ff 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -1,5 +1,7 @@ import React, { Component } from 'react'; +import * as Blockly from 'blockly/core'; + import WorkspaceStats from './WorkspaceStats'; import WorkspaceFunc from './WorkspaceFunc'; import BlocklyWindow from './Blockly/BlocklyWindow'; @@ -15,6 +17,15 @@ class Home extends Component { codeOn: false } + componentDidUpdate(){ + /* Resize and reposition all of the workspace chrome (toolbox, trash, + scrollbars etc.) This should be called when something changes that requires + recalculating dimensions and positions of the trash, zoom, toolbox, etc. + (e.g. window resize). */ + const workspace = Blockly.getMainWorkspace(); + Blockly.svgResize(workspace); + } + onChange = () => { this.setState({ codeOn: !this.state.codeOn }); }