diff --git a/core/flyout.js b/core/flyout.js index c0ca62305..18f37397d 100644 --- a/core/flyout.js +++ b/core/flyout.js @@ -363,7 +363,6 @@ Blockly.Flyout.prototype.show = function(xmlList) { } this.buttons_.length = 0; - this.workspace_.scale = this.targetWorkspace_.scale; var margin = this.CORNER_RADIUS; this.svgGroup_.style.display = 'block'; @@ -466,6 +465,7 @@ Blockly.Flyout.prototype.show = function(xmlList) { * For RTL: Lay out the blocks right-aligned. */ Blockly.Flyout.prototype.reflow = function() { + this.workspace_.scale = this.targetWorkspace_.scale; var flyoutWidth = 0; var margin = this.CORNER_RADIUS; var blocks = this.workspace_.getTopBlocks(false); @@ -484,10 +484,11 @@ Blockly.Flyout.prototype.reflow = function() { var blockHW = block.getHeightWidth(); if (this.RTL) { // With the flyoutWidth known, right-align the blocks. + var oldX = block.getRelativeToSurfaceXY().x; var dx = flyoutWidth - margin; dx /= this.workspace_.scale; dx -= Blockly.BlockSvg.TAB_WIDTH; - block.moveBy(dx, 0); + block.moveBy(dx - oldX, 0); } if (block.flyoutRect_) { block.flyoutRect_.setAttribute('width', blockHW.width); @@ -632,8 +633,13 @@ Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) { } var xyOld = Blockly.getSvgXY_(svgRootOld, workspace); // Scale the scroll (getSvgXY_ did not do this). - xyOld.x += flyout.workspace_.scrollX / flyout.workspace_.scale - - flyout.workspace_.scrollX; + if (flyout.RTL) { + var width = workspace.getMetrics().viewWidth - flyout.width_; + xyOld.x += width / workspace.scale - width; + } else { + xyOld.x += flyout.workspace_.scrollX / flyout.workspace_.scale - + flyout.workspace_.scrollX; + } xyOld.y += flyout.workspace_.scrollY / flyout.workspace_.scale - flyout.workspace_.scrollY; var svgRootNew = block.getSvgRoot(); diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 867080910..53d319331 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -896,7 +896,6 @@ Blockly.WorkspaceSvg.prototype.zoom = function(x, y, type) { Blockly.hideChaff(false); if (this.flyout_) { // No toolbox, resize flyout. - this.flyout_.workspace_.scale = this.scale; this.flyout_.reflow(); } }; @@ -921,6 +920,11 @@ Blockly.WorkspaceSvg.prototype.zoomReset = function() { var metrics = this.getMetrics(); this.scrollbar.set((metrics.contentWidth - metrics.viewWidth) / 2, (metrics.contentHeight - metrics.viewHeight) / 2); + Blockly.hideChaff(false); + if (this.flyout_) { + // No toolbox, resize flyout. + this.flyout_.reflow(); + } }; /**