mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-15 17:23:09 +00:00
Fix click cursor placement on center/right text
This clamps the click cursor placement so that clicking to the left of a short first line of centered/right aligned text positions the cursor to the left of the first character in the line.... Previously in that instance it would move to the left boundary instead
This commit is contained in:
parent
77f304bed0
commit
90a97e6272
1 changed files with 5 additions and 2 deletions
|
|
@ -481,13 +481,16 @@
|
|||
var cursorLocation = this.get2DCursorLocation(),
|
||||
lineIndex = cursorLocation.lineIndex,
|
||||
charIndex = cursorLocation.charIndex,
|
||||
charHeight = this.getCurrentCharFontSize(lineIndex, charIndex);
|
||||
charHeight = this.getCurrentCharFontSize(lineIndex, charIndex),
|
||||
leftOffset = (lineIndex == 0 && charIndex == 0)
|
||||
? this._getCachedLineOffset(lineIndex, this.text.split(this._reNewline))
|
||||
: boundaries.leftOffset;
|
||||
|
||||
ctx.fillStyle = this.getCurrentCharColor(lineIndex, charIndex);
|
||||
ctx.globalAlpha = this.__isMousedown ? 1 : this._currentCursorOpacity;
|
||||
|
||||
ctx.fillRect(
|
||||
boundaries.left + boundaries.leftOffset,
|
||||
boundaries.left + leftOffset,
|
||||
boundaries.top + boundaries.topOffset,
|
||||
this.cursorWidth / this.scaleX,
|
||||
charHeight);
|
||||
|
|
|
|||
Loading…
Reference in a new issue