Skip to content

Commit cab1f2a

Browse files
authored
whay
1 parent d10bcbf commit cab1f2a

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/helper/tools/text-tool.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,14 @@ class TextTool extends paper.Tool {
181181
// (so this.textBox.internalBounds.y is negative).
182182
// Move the transform origin down to the text baseline to match paper
183183
this.element.style.transformOrigin = `${-this.textBox.internalBounds.x}px ${-this.textBox.internalBounds.y}px`;
184-
this.element.style.textAlign = "left";
184+
185185

186186
// In RTL, the element is moved relative to its parent's right edge instead of its left
187187
// edge. We need to correct for this in order for the element to overlap the object in paper.
188188
let tx = 0;
189189
if (this.element.parentElement) {
190-
tx = this.textBox.internalBounds.x;
191-
if (this.alignment === "right") {
192-
this.element.style.textAlign = "right";
193-
} else if (this.alignment === "center") {
194-
this.element.style.textAlign = "center";
195-
this.element.style.transformOrigin = `center ${-this.textBox.internalBounds.y}px`;
196-
}
190+
//tx = this.textBox.internalBounds.x;
191+
if (window.test) window.test(this);
197192
}
198193

199194
// Start by translating the element up so that its (0, 0) is now at the text baseline, like in paper
@@ -338,15 +333,18 @@ class TextTool extends paper.Tool {
338333
// Prevent line from wrapping
339334
this.element.style.width = `${this.textBox.internalBounds.width + 1}px`;
340335
this.element.style.height = `${this.textBox.internalBounds.height}px`;
336+
this.element.style.textAlign = "left";
337+
341338
// The transform origin needs to be updated in RTL because this.textBox.internalBounds.x
342339
// changes as you type
343340
if (this.alignment === "right") {
341+
this.element.style.textAlign = "right";
344342
this.element.style.transformOrigin =
345343
`${-this.textBox.internalBounds.x}px ${-this.textBox.internalBounds.y}px`;
346344
}
347-
if (this.alignment === "center") {
348-
this.element.style.transformOrigin =
349-
`${-this.textBox.internalBounds.x / 2}px ${-this.textBox.internalBounds.y}px`;
345+
if (this.alignment === "center") {
346+
this.element.style.textAlign = "center";
347+
this.element.style.transformOrigin = `center ${-this.textBox.internalBounds.y}px`;
350348
}
351349
}
352350
beginSelect () {

0 commit comments

Comments
 (0)