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.isBlinking = blinking;
|
||||
if (blinking)
|
||||
this.restartTimer();
|
||||
this.resetTimer();
|
||||
};
|
||||
|
||||
this.addCursor = function() {
|
||||
|
|
@ -88,32 +87,41 @@ var Cursor = function(parentEl) {
|
|||
this.isVisible = false;
|
||||
for (var i = this.cursors.length; i--; )
|
||||
dom.addCssClass(this.cursors[i], "ace_hidden");
|
||||
clearInterval(this.blinkId);
|
||||
this.resetTimer();
|
||||
};
|
||||
|
||||
this.showCursor = function() {
|
||||
this.isVisible = true;
|
||||
for (var i = this.cursors.length; i--; )
|
||||
dom.removeCssClass(this.cursors[i], "ace_hidden");
|
||||
|
||||
this.element.style.visibility = "";
|
||||
this.restartTimer();
|
||||
this.resetTimer();
|
||||
};
|
||||
|
||||
this.restartTimer = function() {
|
||||
clearInterval(this.blinkId);
|
||||
if (!this.isBlinking)
|
||||
return;
|
||||
if (!this.isVisible)
|
||||
this.resetTimer = function() {
|
||||
clearInterval(this.intervalId);
|
||||
clearTimeout(this.timeoutId);
|
||||
for (var i = this.cursors.length; i--; )
|
||||
this.cursors[i].style.visibility = "";
|
||||
|
||||
if (!this.isBlinking || !this.isVisible)
|
||||
return;
|
||||
|
||||
var element = this.cursors.length == 1 ? this.cursor : this.element;
|
||||
this.blinkId = setInterval(function() {
|
||||
element.style.visibility = "hidden";
|
||||
setTimeout(function() {
|
||||
element.style.visibility = "";
|
||||
}, 400);
|
||||
}, 1000);
|
||||
var blink = function(){
|
||||
this.timeoutId = setTimeout(function() {
|
||||
for (var i = this.cursors.length; i--; ) {
|
||||
this.cursors[i].style.visibility = "hidden";
|
||||
}
|
||||
}.bind(this), 0.6 * 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) {
|
||||
|
|
@ -170,7 +178,7 @@ var Cursor = function(parentEl) {
|
|||
|
||||
// cache for textarea and gutter highlight
|
||||
this.$pixelPos = pixelPos;
|
||||
this.restartTimer();
|
||||
this.resetTimer();
|
||||
};
|
||||
|
||||
this.$setOverwrite = function(overwrite) {
|
||||
|
|
@ -186,7 +194,8 @@ var Cursor = function(parentEl) {
|
|||
};
|
||||
|
||||
this.destroy = function() {
|
||||
clearInterval(this.blinkId);
|
||||
clearInterval(this.intervalId);
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
|
||||
}).call(Cursor.prototype);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue