mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
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:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user