Rename restartTimer to resetTimer in cursor, refactor this method
This commit is contained in:
parent
c2c650db1c
commit
4a38512616
1 changed files with 29 additions and 20 deletions
|
|
@ -58,8 +58,7 @@ var Cursor = function(parentEl) {
|
||||||
|
|
||||||
this.setBlinking = function(blinking) {
|
this.setBlinking = function(blinking) {
|
||||||
this.isBlinking = blinking;
|
this.isBlinking = blinking;
|
||||||
if (blinking)
|
this.resetTimer();
|
||||||
this.restartTimer();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.addCursor = function() {
|
this.addCursor = function() {
|
||||||
|
|
@ -88,32 +87,41 @@ var Cursor = function(parentEl) {
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
for (var i = this.cursors.length; i--; )
|
for (var i = this.cursors.length; i--; )
|
||||||
dom.addCssClass(this.cursors[i], "ace_hidden");
|
dom.addCssClass(this.cursors[i], "ace_hidden");
|
||||||
clearInterval(this.blinkId);
|
this.resetTimer();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.showCursor = function() {
|
this.showCursor = function() {
|
||||||
this.isVisible = true;
|
this.isVisible = true;
|
||||||
for (var i = this.cursors.length; i--; )
|
for (var i = this.cursors.length; i--; )
|
||||||
dom.removeCssClass(this.cursors[i], "ace_hidden");
|
dom.removeCssClass(this.cursors[i], "ace_hidden");
|
||||||
|
this.resetTimer();
|
||||||
this.element.style.visibility = "";
|
|
||||||
this.restartTimer();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.restartTimer = function() {
|
this.resetTimer = function() {
|
||||||
clearInterval(this.blinkId);
|
clearInterval(this.intervalId);
|
||||||
if (!this.isBlinking)
|
clearTimeout(this.timeoutId);
|
||||||
return;
|
for (var i = this.cursors.length; i--; )
|
||||||
if (!this.isVisible)
|
this.cursors[i].style.visibility = "";
|
||||||
|
|
||||||
|
if (!this.isBlinking || !this.isVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var element = this.cursors.length == 1 ? this.cursor : this.element;
|
var blink = function(){
|
||||||
this.blinkId = setInterval(function() {
|
this.timeoutId = setTimeout(function() {
|
||||||
element.style.visibility = "hidden";
|
for (var i = this.cursors.length; i--; ) {
|
||||||
setTimeout(function() {
|
this.cursors[i].style.visibility = "hidden";
|
||||||
element.style.visibility = "";
|
}
|
||||||
}, 400);
|
}.bind(this), 0.6 * 1000);
|
||||||
}, 1000);
|
}.bind(this);
|
||||||
|
|
||||||
|
this.intervalId = setInterval(function() {
|
||||||
|
for (var i = this.cursors.length; i--; ) {
|
||||||
|
this.cursors[i].style.visibility = "";
|
||||||
|
}
|
||||||
|
blink();
|
||||||
|
}.bind(this), 1000);
|
||||||
|
|
||||||
|
blink();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getPixelPosition = function(position, onScreen) {
|
this.getPixelPosition = function(position, onScreen) {
|
||||||
|
|
@ -170,7 +178,7 @@ var Cursor = function(parentEl) {
|
||||||
|
|
||||||
// cache for textarea and gutter highlight
|
// cache for textarea and gutter highlight
|
||||||
this.$pixelPos = pixelPos;
|
this.$pixelPos = pixelPos;
|
||||||
this.restartTimer();
|
this.resetTimer();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$setOverwrite = function(overwrite) {
|
this.$setOverwrite = function(overwrite) {
|
||||||
|
|
@ -186,7 +194,8 @@ var Cursor = function(parentEl) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.destroy = function() {
|
this.destroy = function() {
|
||||||
clearInterval(this.blinkId);
|
clearInterval(this.intervalId);
|
||||||
|
clearTimeout(this.timeoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}).call(Cursor.prototype);
|
}).call(Cursor.prototype);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue