app/assets/htmls/gs-element-blockly.html in gobstones-blockly-0.14.0 vs app/assets/htmls/gs-element-blockly.html in gobstones-blockly-0.15.0

- old
+ new

@@ -6582,9 +6582,26 @@ */ showBlockError: function(blockId, errorKind) { this.workspace.showBlockError(blockId, errorKind); }, + scrollToBlock: function(blockId) { + const block = blockId + ? this.workspace.getBlockById(blockId) + : this.workspace.getAllBlocks().find((it) => it.type === "Program"); + if (!block) return; + + const position = block.getRelativeToSurfaceXY(); + const { viewLeft, contentLeft, viewTop, contentTop, viewWidth, viewHeight } = this.workspace.getMetrics(); + + const finalPosition = { + x: position.x - viewWidth / 4 - contentLeft, + y: position.y - viewHeight / 2 - contentTop + }; + + this.workspace.scrollbar.set(finalPosition.x, finalPosition.y); + }, + testColors(colors) { Blockly.CUSTOM_COLORS = colors; Blockly.HSV_SATURATION = colors.globalHsvSaturation; Blockly.HSV_VALUE = colors.globalHsvValue; Blockly.Blocks.procedures.HUE = colors.procedure; \ No newline at end of file