Skip to content

Commit 610c07c

Browse files
Fixes for update
1 parent caf7d73 commit 610c07c

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

frontend/stepper/js/blockly_interface.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class BlocklyInterface {
9999
private limitedPointers: any;
100100
private blockCounts: any;
101101
private dragJustTerminated: boolean;
102+
private prevWidth: number;
102103

103104
constructor(maxBlocks, subTask) {
104105
this.subTask = subTask;
@@ -173,7 +174,7 @@ class BlocklyInterface {
173174

174175
this.options = options;
175176

176-
addExtraBlocks(this.strings, this.getDefaultColours());
177+
addExtraBlocks(this.strings, this.getDefaultColours(), !this.mainContext.infos || !this.mainContext.infos.showIfMutator);
177178
this.createSimpleGeneratorsAndBlocks();
178179

179180
this.display = display;
@@ -427,6 +428,24 @@ class BlocklyInterface {
427428
window.jQuery("#program").val(this.programs[this.codeId].javascript);
428429
}
429430

431+
updateSize(force) {
432+
let panelWidth = 500;
433+
if (this.languages[this.codeId] == "blockly") {
434+
panelWidth = window.jQuery("#blocklyDiv").width() - 10;
435+
} else {
436+
panelWidth = window.jQuery("#program").width() + 20;
437+
}
438+
if (force || panelWidth != this.prevWidth) {
439+
if (this.languages[this.codeId] == "blockly") {
440+
if (this.trashInToolbox) {
441+
window.Blockly.Trashcan.prototype.MARGIN_SIDE_ = panelWidth - 90;
442+
}
443+
window.Blockly.svgResize(this.workspace);
444+
}
445+
}
446+
this.prevWidth = panelWidth;
447+
}
448+
430449
highlightBlock(id, keep) {
431450
if (!id) {
432451
keep = false;

frontend/stepper/js/extra_blocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function addExtraBlocks(strings, defaultColors) {
1+
export function addExtraBlocks(strings, defaultColors, showIfMutator ) {
22
window.Blockly.Blocks['controls_untilWhile'] = window.Blockly.Blocks['controls_whileUntil'];
33
window.Blockly.JavaScript['controls_untilWhile'] = window.Blockly.JavaScript['controls_whileUntil'];
44
window.Blockly.Python['controls_untilWhile'] = window.Blockly.Python['controls_whileUntil'];
@@ -219,7 +219,7 @@ export function addExtraBlocks(strings, defaultColors) {
219219
};
220220

221221
} else {
222-
if (!this.mainContext.infos || !this.mainContext.infos.showIfMutator) {
222+
if (!showIfMutator) {
223223
var old = window.Blockly.Blocks.controls_if.init;
224224
window.Blockly.Blocks.controls_if.init = function () {
225225
old.call(this);

0 commit comments

Comments
 (0)