recalculating positions of trash, zoom, etc
This commit is contained in:
parent
338bec2d59
commit
9f33b93fdd
@ -22,7 +22,6 @@ export const onChangeWorkspace = (event) => (dispatch, getState) => {
|
|||||||
type: NEW_CODE,
|
type: NEW_CODE,
|
||||||
payload: code
|
payload: code
|
||||||
});
|
});
|
||||||
console.log(event.type);
|
|
||||||
var stats = getState().workspace.stats;
|
var stats = getState().workspace.stats;
|
||||||
if (event.type === Blockly.Events.BLOCK_CREATE){
|
if (event.type === Blockly.Events.BLOCK_CREATE){
|
||||||
stats.create += event.ids.length;
|
stats.create += event.ids.length;
|
||||||
|
@ -20,6 +20,7 @@ class BlocklyWindow extends Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const workspace = Blockly.getMainWorkspace();
|
const workspace = Blockly.getMainWorkspace();
|
||||||
|
this.props.onChangeWorkspace({});
|
||||||
workspace.addChangeListener((event) => {
|
workspace.addChangeListener((event) => {
|
||||||
this.props.onChangeWorkspace(event);
|
this.props.onChangeWorkspace(event);
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
|
import * as Blockly from 'blockly/core';
|
||||||
|
|
||||||
import WorkspaceStats from './WorkspaceStats';
|
import WorkspaceStats from './WorkspaceStats';
|
||||||
import WorkspaceFunc from './WorkspaceFunc';
|
import WorkspaceFunc from './WorkspaceFunc';
|
||||||
import BlocklyWindow from './Blockly/BlocklyWindow';
|
import BlocklyWindow from './Blockly/BlocklyWindow';
|
||||||
@ -15,6 +17,15 @@ class Home extends Component {
|
|||||||
codeOn: false
|
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 = () => {
|
onChange = () => {
|
||||||
this.setState({ codeOn: !this.state.codeOn });
|
this.setState({ codeOn: !this.state.codeOn });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user