File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 6
6
7
7
transition : 0.07s ;
8
8
z-index : 3 ;
9
+ }
10
+
11
+ .blink-caret {
12
+ animation : blink 1s 1s infinite;
13
+ }
14
+
15
+ @keyframes blink{
16
+ 0% {opacity : 0 ;}
17
+ 50% {opacity : 100% ;}
9
18
}
Original file line number Diff line number Diff line change 1
1
# code_editor {
2
2
background-color : rgb (39 , 39 , 39 );
3
3
overflow-y : auto;
4
+ cursor : text;
4
5
/* overflow-x: hidden; */
5
6
}
6
7
.caret {
Original file line number Diff line number Diff line change @@ -16,11 +16,13 @@ Caret.prototype = {
16
16
} ,
17
17
18
18
setPos : function ( row , col ) {
19
+ this . resetBlink ( ) ;
20
+
19
21
this . row = row ;
20
22
this . col = col ;
21
23
22
24
let el = this . getCharacterElementBefore ( ) ;
23
- let caretElement = $ ( `#caret_ ${ this . page . getId ( ) } _ ${ this . id } ` ) ;
25
+ let caretElement = this . getCarretElement ( ) ;
24
26
let lineEl , linenumEl , linecodeEl ;
25
27
26
28
let top , left ;
@@ -265,5 +267,19 @@ Caret.prototype = {
265
267
let line_ref = _this . page . getLineRef ( line_num ) ;
266
268
_this . setPos ( line_num , line_ref . getCharCount ( ) + 1 ) ;
267
269
}
270
+ } ,
271
+
272
+ getCarretElement : function ( ) {
273
+ return $ ( `#caret_${ this . page . getId ( ) } _${ this . id } ` ) ;
274
+ } ,
275
+
276
+ resetBlink : function ( ) {
277
+ let carret = this . getCarretElement ( ) ;
278
+ carret . removeClass ( "blink-caret" ) ;
279
+
280
+ // Timeout avoids continuation of blink animation
281
+ window . setTimeout ( ( ) => {
282
+ carret . addClass ( "blink-caret" ) ;
283
+ } , 500 ) ; ;
268
284
}
269
285
}
You can’t perform that action at this time.
0 commit comments