Skip to content

Commit 9f1da96

Browse files
authored
fix: fix positioning of block comments in RTL mode (#249)
* fix: fix positioning of block comments in RTL mode * chore: factor out shared constant
1 parent dc17159 commit 9f1da96

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/scratch_comment_bubble.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,19 @@ export class ScratchCommentBubble
129129
}
130130

131131
dropAnchor() {
132-
this.moveTo(this.anchor.x + 40, this.anchor.y - 16);
132+
const verticalOffset = 16;
133+
this.moveTo(
134+
this.anchor.x + 40 * (this.workspace.RTL ? -1 : 1),
135+
this.anchor.y - verticalOffset
136+
);
133137
const location = this.getRelativeToSurfaceXY();
134138
this.anchorChain = Blockly.utils.dom.createSvgElement(
135139
Blockly.utils.Svg.LINE,
136140
{
137141
x1: this.anchor.x - location.x,
138142
y1: this.anchor.y - location.y,
139-
x2: this.getSize().width / 2,
140-
y2: 16,
143+
x2: (this.getSize().width / 2) * (this.workspace.RTL ? -1 : 1),
144+
y2: verticalOffset,
141145
style: `stroke: ${this.sourceBlock.getColourTertiary()}; stroke-width: 1`,
142146
},
143147
this.getSvgRoot()

0 commit comments

Comments
 (0)