diff --git a/core/renderers/common/drawer.js b/core/renderers/common/drawer.js index 2592d2171..f36464373 100644 --- a/core/renderers/common/drawer.js +++ b/core/renderers/common/drawer.js @@ -77,6 +77,9 @@ Blockly.blockRendering.Drawer.prototype.draw = function() { this.drawInternals_(); this.block_.pathObject.setPaths(this.outlinePath_ + '\n' + this.inlinePath_); + if (this.info_.RTL) { + this.block_.pathObject.flipRTL(); + } if (Blockly.blockRendering.useDebugger) { this.block_.renderingDebugger.drawDebug(this.block_, this.info_); } diff --git a/core/renderers/common/path_object.js b/core/renderers/common/path_object.js index e5a22282b..a3bde956e 100644 --- a/core/renderers/common/path_object.js +++ b/core/renderers/common/path_object.js @@ -30,6 +30,7 @@ goog.provide('Blockly.blockRendering.PathObject'); goog.require('Blockly.utils.dom'); + /** * An interface for a block's path object. * @param {!SVGElement} _root The root SVG element. @@ -86,11 +87,15 @@ Blockly.blockRendering.PathObject = function(root) { */ Blockly.blockRendering.PathObject.prototype.setPaths = function(pathString) { this.svgPath.setAttribute('d', pathString); - if (this.RTL) { - // Mirror the block's path. - this.svgPath.setAttribute('transform', 'scale(-1 1)'); - } - this.svgPathLight.style.display = 'none'; this.svgPathDark.style.display = 'none'; }; + +/** + * Flip the SVG paths in RTL. + * @package + */ +Blockly.blockRendering.PathObject.prototype.flipRTL = function() { + // Mirror the block's path. + this.svgPath.setAttribute('transform', 'scale(-1 1)'); +}; diff --git a/core/renderers/geras/drawer.js b/core/renderers/geras/drawer.js index c4cd209c2..551611c19 100644 --- a/core/renderers/geras/drawer.js +++ b/core/renderers/geras/drawer.js @@ -62,7 +62,9 @@ Blockly.geras.Drawer.prototype.draw = function() { this.block_.pathObject.setPaths(this.outlinePath_ + '\n' + this.inlinePath_, this.highlighter_.getPath()); - + if (this.info_.RTL) { + this.block_.pathObject.flipRTL(); + } if (Blockly.blockRendering.useDebugger) { this.block_.renderingDebugger.drawDebug(this.block_, this.info_); } diff --git a/core/renderers/geras/path_object.js b/core/renderers/geras/path_object.js index 5a275af57..4a7f544d7 100644 --- a/core/renderers/geras/path_object.js +++ b/core/renderers/geras/path_object.js @@ -62,7 +62,6 @@ Blockly.geras.PathObject = function(root) { this.svgPath = Blockly.utils.dom.createSvgElement('path', {'class': 'blocklyPath'}, this.svgRoot); - /** * The light path of the block. * @type {SVGElement} @@ -82,10 +81,15 @@ Blockly.geras.PathObject.prototype.setPaths = function(mainPath, highlightPath) this.svgPath.setAttribute('d', mainPath); this.svgPathDark.setAttribute('d', mainPath); this.svgPathLight.setAttribute('d', highlightPath); - if (this.RTL) { - // Mirror the block's path. - this.svgPath.setAttribute('transform', 'scale(-1 1)'); - this.svgPathLight.setAttribute('transform', 'scale(-1 1)'); - this.svgPathDark.setAttribute('transform', 'translate(1,1) scale(-1 1)'); - } +}; + +/** + * Flip the SVG paths in RTL. + * @package + */ +Blockly.geras.PathObject.prototype.flipRTL = function() { + // Mirror the block's path. + this.svgPath.setAttribute('transform', 'scale(-1 1)'); + this.svgPathLight.setAttribute('transform', 'scale(-1 1)'); + this.svgPathDark.setAttribute('transform', 'translate(1,1) scale(-1 1)'); };