Add blinkInterval option to cursor
This commit is contained in:
parent
4a38512616
commit
aa9962aafd
1 changed files with 16 additions and 6 deletions
|
|
@ -40,6 +40,7 @@ var Cursor = function(parentEl) {
|
|||
|
||||
this.isVisible = false;
|
||||
this.isBlinking = true;
|
||||
this.blinkInterval = 1000;
|
||||
|
||||
this.cursors = [];
|
||||
this.cursor = this.addCursor();
|
||||
|
|
@ -57,8 +58,17 @@ var Cursor = function(parentEl) {
|
|||
};
|
||||
|
||||
this.setBlinking = function(blinking) {
|
||||
this.isBlinking = blinking;
|
||||
this.resetTimer();
|
||||
if (blinking != this.isBlinking){
|
||||
this.isBlinking = blinking;
|
||||
this.resetTimer();
|
||||
}
|
||||
};
|
||||
|
||||
this.setBlinkInterval = function(blinkInterval) {
|
||||
if (blinkInterval != this.blinkInterval){
|
||||
this.blinkInterval = blinkInterval;
|
||||
this.resetTimer();
|
||||
}
|
||||
};
|
||||
|
||||
this.addCursor = function() {
|
||||
|
|
@ -103,7 +113,7 @@ var Cursor = function(parentEl) {
|
|||
for (var i = this.cursors.length; i--; )
|
||||
this.cursors[i].style.visibility = "";
|
||||
|
||||
if (!this.isBlinking || !this.isVisible)
|
||||
if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
|
||||
return;
|
||||
|
||||
var blink = function(){
|
||||
|
|
@ -111,7 +121,7 @@ var Cursor = function(parentEl) {
|
|||
for (var i = this.cursors.length; i--; ) {
|
||||
this.cursors[i].style.visibility = "hidden";
|
||||
}
|
||||
}.bind(this), 0.6 * 1000);
|
||||
}.bind(this), 0.6 * this.blinkInterval);
|
||||
}.bind(this);
|
||||
|
||||
this.intervalId = setInterval(function() {
|
||||
|
|
@ -119,7 +129,7 @@ var Cursor = function(parentEl) {
|
|||
this.cursors[i].style.visibility = "";
|
||||
}
|
||||
blink();
|
||||
}.bind(this), 1000);
|
||||
}.bind(this), this.blinkInterval);
|
||||
|
||||
blink();
|
||||
};
|
||||
|
|
@ -196,7 +206,7 @@ var Cursor = function(parentEl) {
|
|||
this.destroy = function() {
|
||||
clearInterval(this.intervalId);
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
};
|
||||
|
||||
}).call(Cursor.prototype);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue