diff --git a/src/components/sprite-info/sprite-info.jsx b/src/components/sprite-info/sprite-info.jsx index e9090bfe387260e6735b1ec4e9576eed43edc50e..09c94d0162a155fd13d4cf5ede81aa47878d3889 100644 --- a/src/components/sprite-info/sprite-info.jsx +++ b/src/components/sprite-info/sprite-info.jsx @@ -34,14 +34,15 @@ class SpriteInfo extends React.Component { shouldComponentUpdate (nextProps) { return ( this.props.rotationStyle !== nextProps.rotationStyle || - this.props.direction !== nextProps.direction || this.props.disabled !== nextProps.disabled || this.props.name !== nextProps.name || - this.props.size !== nextProps.size || this.props.stageSize !== nextProps.stageSize || this.props.visible !== nextProps.visible || - this.props.x !== nextProps.x || - this.props.y !== nextProps.y + // Only update these if rounded value has changed + Math.round(this.props.direction) !== Math.round(nextProps.direction) || + Math.round(this.props.size) !== Math.round(nextProps.size) || + Math.round(this.props.x) !== Math.round(nextProps.x) || + Math.round(this.props.y) !== Math.round(nextProps.y) ); } render () { @@ -110,7 +111,7 @@ class SpriteInfo extends React.Component { placeholder="x" tabIndex="0" type="text" - value={this.props.disabled ? '' : this.props.x} + value={this.props.disabled ? '' : Math.round(this.props.x)} onSubmit={this.props.onChangeX} /> </Label> @@ -137,7 +138,7 @@ class SpriteInfo extends React.Component { placeholder="y" tabIndex="0" type="text" - value={this.props.disabled ? '' : this.props.y} + value={this.props.disabled ? '' : Math.round(this.props.y)} onSubmit={this.props.onChangeY} /> </Label> @@ -237,14 +238,14 @@ class SpriteInfo extends React.Component { label={sizeLabel} tabIndex="0" type="text" - value={this.props.disabled ? '' : this.props.size} + value={this.props.disabled ? '' : Math.round(this.props.size)} onSubmit={this.props.onChangeSize} /> </Label> </div> <div className={classNames(styles.group, styles.largerInput)}> <DirectionPicker - direction={this.props.direction} + direction={Math.round(this.props.direction)} disabled={this.props.disabled} labelAbove={labelAbove} rotationStyle={this.props.rotationStyle} diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index f64e7c30768639d0af1901590d6aba8947216a46..a3bf5872283fd3458ab45fce683f0bf0bdb370d2 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -170,13 +170,16 @@ class Blocks extends React.Component { } setLocale () { - this.workspace.getFlyout().setRecyclingEnabled(false); this.ScratchBlocks.ScratchMsgs.setLocale(this.props.locale); this.props.vm.setLocale(this.props.locale, this.props.messages) .then(() => { + this.workspace.getFlyout().setRecyclingEnabled(false); this.props.vm.refreshWorkspace(); - this.updateToolbox(); - this.workspace.getFlyout().setRecyclingEnabled(true); + // refreshWorkspace will cause a toolbox update + // wait for update to go through before reenabling recycling + this.withToolboxUpdates(() => { + this.workspace.getFlyout().setRecyclingEnabled(true); + }); }); } diff --git a/src/containers/target-pane.jsx b/src/containers/target-pane.jsx index eb41009694069c54b7bc26409fd655e11c844c73..16017423c903b881176569fc9255d13daea02d77 100644 --- a/src/containers/target-pane.jsx +++ b/src/containers/target-pane.jsx @@ -251,19 +251,12 @@ TargetPane.propTypes = { const mapStateToProps = state => ({ editingTarget: state.scratchGui.targets.editingTarget, hoveredTarget: state.scratchGui.hoveredTarget, - sprites: Object.keys(state.scratchGui.targets.sprites).reduce((sprites, k) => { - let {direction, size, x, y, ...sprite} = state.scratchGui.targets.sprites[k]; - if (typeof direction !== 'undefined') direction = Math.round(direction); - if (typeof x !== 'undefined') x = Math.round(x); - if (typeof y !== 'undefined') y = Math.round(y); - if (typeof size !== 'undefined') size = Math.round(size); - sprites[k] = {...sprite, direction, size, x, y}; - return sprites; - }, {}), + sprites: state.scratchGui.targets.sprites, stage: state.scratchGui.targets.stage, raiseSprites: state.scratchGui.blockDrag, spriteLibraryVisible: state.scratchGui.modals.spriteLibrary }); + const mapDispatchToProps = dispatch => ({ onNewSpriteClick: e => { e.preventDefault();