Skip to content

Commit

Permalink
avoid having multiple blinking cursors on rapid focus change
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Oct 29, 2020
1 parent e9f53dd commit a719391
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/ace/layer/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ var Cursor = function(parentEl) {
for (var i = cursors.length; i--; )
cursors[i].style.animationDuration = this.blinkInterval + "ms";

this.$isAnimating = true;
setTimeout(function() {
dom.addCssClass(this.element, "ace_animate-blinking");
if (this.$isAnimating) {
dom.addCssClass(this.element, "ace_animate-blinking");
}
}.bind(this));
};

this.$stopCssAnimation = function() {
this.$isAnimating = false;
dom.removeCssClass(this.element, "ace_animate-blinking");
};

Expand Down Expand Up @@ -138,6 +142,7 @@ var Cursor = function(parentEl) {
this.$stopCssAnimation();

if (this.smoothBlinking) {
this.$isSmoothBlinking = false;
dom.removeCssClass(this.element, "ace_smooth-blinking");
}

Expand All @@ -149,8 +154,11 @@ var Cursor = function(parentEl) {
}

if (this.smoothBlinking) {
setTimeout(function(){
dom.addCssClass(this.element, "ace_smooth-blinking");
this.$isSmoothBlinking = true;
setTimeout(function() {
if (this.$isSmoothBlinking) {
dom.addCssClass(this.element, "ace_smooth-blinking");
}
}.bind(this));
}

Expand Down

0 comments on commit a719391

Please sign in to comment.