diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index ccc6d3f7c94..5de2bed3cb8 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -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"); }; @@ -138,6 +142,7 @@ var Cursor = function(parentEl) { this.$stopCssAnimation(); if (this.smoothBlinking) { + this.$isSmoothBlinking = false; dom.removeCssClass(this.element, "ace_smooth-blinking"); } @@ -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)); }