Skip to content

Commit 22689c6

Browse files
committed
fixed caret css position
1 parent a1cb7b7 commit 22689c6

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

css/caret.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.caret {
2+
position: absolute;
3+
height: 2.6vh;
4+
left: 1px;
5+
border-right: 1px solid black;
6+
7+
transition: 0.07s;
8+
}

css/index.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ body {
1717
z-index: 0;
1818
}
1919

20-
.caret {
21-
position: absolute;
22-
height: 2.6vh;
23-
left: 1px;
24-
border-right: 1px solid black;
25-
26-
transition: 0.07s;
27-
}
28-
2920
.line {
3021
position: relative;
3122
top: 0px;

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<head>
55
<link rel="stylesheet" type="text/css" href="css/index.css">
6+
<link rel="stylesheet" type="text/css" href="css/caret.css">
67
</head>
78

89
<body>

js/caret.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ Caret.prototype = {
2424
let top, left;
2525
if(this.row == 1) top = 0;
2626
else top = $(`.line:nth-child(${this.row})`).position().top;
27-
if(this.col == 1 || el == undefined) left = 15;
27+
if(this.col == 1 || el == undefined) {
28+
if(el == undefined) {
29+
left = $(`.line:nth-child(${this.row}) .linenum`).width() + 10;
30+
console.log(`> ${left}`);
31+
} else
32+
left = 15;
33+
}
2834
else left = $(el).position().left + $(el).width();
2935

3036
caretElement.style.top = `${top}px`;

js/keyboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const keyToChar = function(keyCode) {
4646
// KEYDOWN
4747
const handleKeyDown = function(keyCode) {
4848
var tmpkey = String.fromCharCode(keyCode);
49-
console.log(tmpkey + ' ' + keyCode);
49+
// console.log(tmpkey + ' ' + keyCode);
5050

5151
// TRIGGER HELPER KEYS: CTRL, SHIFT
5252
if(keyCode == shiftKey.keyCode) {

0 commit comments

Comments
 (0)