From 317db942d55ecfed9d7f49452ac52d53c02903a2 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Mon, 21 Sep 2015 16:23:33 -0700 Subject: [PATCH] Fix jump when blocks are added from top of flyout. Issue 179. --- core/blockly.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/blockly.js b/core/blockly.js index 838caa035..f50fbbf24 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -47,7 +47,7 @@ goog.require('Blockly.Procedures'); Blockly.Realtime = { isEnabled: function() {return false;}, blockChanged: function() {}, - doCommand: function(cmdThunk) {cmdThunk()} + doCommand: function(cmdThunk) {cmdThunk();} }; goog.require('Blockly.Toolbox'); goog.require('Blockly.WidgetDiv'); @@ -522,8 +522,11 @@ Blockly.getMainWorkspaceMetrics_ = function() { if (this.toolbox_) { svgSize.width -= this.toolbox_.width; } - var viewWidth = svgSize.width - Blockly.Scrollbar.scrollbarThickness; - var viewHeight = svgSize.height - Blockly.Scrollbar.scrollbarThickness; + // Set the margin to match the flyout's margin so that the workspace does + // not jump as blocks are added. + var MARGIN = Blockly.Flyout.prototype.CORNER_RADIUS - 1; + var viewWidth = svgSize.width - MARGIN; + var viewHeight = svgSize.height - MARGIN; try { var blockBox = this.getCanvas().getBBox(); } catch (e) {