Merge pull request #2784 from moniika/moniika-rtl-image-flip

Adding logic to flip FieldImages in RTL with flipRtl flag set.
This commit is contained in:
Monica Kozbial
2019-08-07 13:15:16 -07:00
committed by GitHub
2 changed files with 8 additions and 1 deletions

View File

@@ -315,15 +315,21 @@ Blockly.blockRendering.Drawer.prototype.layoutField_ = function(fieldInfo) {
var yPos = fieldInfo.centerline - fieldInfo.height / 2;
var xPos = fieldInfo.xPos;
var scale = '';
if (this.info_.RTL) {
xPos = -(xPos + fieldInfo.width);
if (fieldInfo.flipRtl) {
xPos += fieldInfo.width;
scale = 'scale(-1 1)';
}
}
if (fieldInfo.type == 'icon') {
svgGroup.setAttribute('display', 'block');
svgGroup.setAttribute('transform', 'translate(' + xPos + ',' + yPos + ')');
fieldInfo.icon.computeIconLocation();
} else {
svgGroup.setAttribute('transform', 'translate(' + xPos + ',' + yPos + ')');
svgGroup.setAttribute(
'transform', 'translate(' + xPos + ',' + yPos + ')' + scale);
}
if (this.info_.isInsertionMarker) {

View File

@@ -215,6 +215,7 @@ Blockly.blockRendering.Field = function(field, parentInput) {
Blockly.blockRendering.Field.superClass_.constructor.call(this);
this.field = field;
this.isEditable = field.isCurrentlyEditable();
this.flipRtl = field instanceof Blockly.FieldImage && field.getFlipRtl();
this.type = 'field';
var size = this.field.getSize();