mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-09 21:51:29 +08:00
fix(caret): incorrect underline positioning
This commit is contained in:
parent
5526088142
commit
79b79e0519
2 changed files with 7 additions and 3 deletions
|
|
@ -72,6 +72,5 @@
|
|||
&.underline {
|
||||
height: 0.1em;
|
||||
width: 0.5em;
|
||||
margin-top: 1.2em;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -519,10 +519,15 @@ export class Caret {
|
|||
top += options.letter.offsetTop;
|
||||
top += options.word.offsetTop;
|
||||
|
||||
// center the caret vertically and horizontally
|
||||
if (this.style !== "underline") {
|
||||
if (this.style === "underline") {
|
||||
// if style is underline, add the height of the letter to the top
|
||||
top += options.letter.offsetHeight;
|
||||
} else {
|
||||
// else center vertically in the letter
|
||||
top += (options.letter.offsetHeight - this.getHeight()) / 2;
|
||||
}
|
||||
|
||||
// also center horizontally
|
||||
if (!this.isFullWidth()) {
|
||||
left += (this.getWidth() / 2) * -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue