Skip to content

Commit b9c52d6

Browse files
committed
refactor: use bare CSS to override builtin cursor animation
1 parent 46c77d4 commit b9c52d6

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

main.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export default class AnimatedCursorPlugin extends Plugin {
5555

5656
_iterMarkdownView(this.app, view => {
5757
let cursorPlugin = hookCursorPlugin(view.editor.cm);
58-
cursorPlugin?.dom.style.setProperty("animation-name", "cm-blink");
5958
cursorPlugin?.dom.removeClass("cm-blinkLayer");
6059
});
6160

@@ -80,11 +79,6 @@ export default class AnimatedCursorPlugin extends Plugin {
8079
this.originalLayerConfig = patchCursorPlugin(cursorPlugin);
8180
this.alreadyPatched = true;
8281

83-
_iterMarkdownView(this.app, view => {
84-
let cursorPlugin = hookCursorPlugin(view.editor.cm);
85-
cursorPlugin?.dom.style.removeProperty("animation-name");
86-
});
87-
8882
// Detach the handler after a successful attemp.
8983
this.app.workspace.off("active-leaf-change", this.tryPatch);
9084
}

styles.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ settings:
5656
}
5757
&>.cm-scroller>.cm-layer.cm-cursorLayer {
5858
&.cm-blinkLayer {
59-
animation-name: cm-cursor-blink;
59+
animation-name: cm-cursor-blink !important;
6060
animation-duration: calc(var(--cursor-blink-rate) / 2) !important;
6161
animation-timing-function: var(--cursor-blink-easing);
6262
animation-direction: alternate-reverse;
@@ -66,7 +66,9 @@ settings:
6666
}
6767
}
6868
&:not(.cm-blinkLayer) {
69-
animation: none;
69+
animation-name: none !important;
70+
animation-duration: 0 !important;
71+
animation: none !important;
7072
}
7173
&>.cm-cursor {
7274
transition-property: top, left, height;

0 commit comments

Comments
 (0)