Use CSS animations

This commit is contained in:
Daniel Imms 2016-06-14 10:52:49 -07:00
parent 253babff62
commit 0d803ac895
2 changed files with 20 additions and 23 deletions

View File

@ -57,6 +57,21 @@
background-color: transparent;
}
.terminal .terminal-cursor.blinking {
animation: blink-cursor 1.2s infinite step-end;
}
@keyframes blink-cursor {
0% {
background-color: #fff;
color: #000;
}
50% {
background-color: transparent;
color: #FFF;
}
}
/*
* Determine default colors for xterm.js
*/

View File

@ -765,9 +765,6 @@
// Ensure there is a Terminal.focus.
this.focus();
// Start blinking the cursor.
this.startBlink();
on(this.element, 'mouseup', function() {
var selection = document.getSelection(),
collapsed = selection.isCollapsed,
@ -1250,7 +1247,11 @@
}
if (data !== this.defAttr) {
if (data === -1) {
out += '<span class="reverse-video terminal-cursor">';
out += '<span class="reverse-video terminal-cursor';
if (this.cursorBlink) {
out += ' blinking';
}
out += '">';
} else {
var classNames = [];
@ -1363,32 +1364,13 @@
this.emit('refresh', {element: this.element, start: start, end: end});
};
Terminal.prototype._cursorBlink = function() {
if (document.activeElement !== this.element) return;
this.cursorState ^= 1;
this.refresh(this.y, this.y);
};
Terminal.prototype.showCursor = function() {
if (!this.cursorState) {
this.cursorState = 1;
this.refresh(this.y, this.y);
} else {
this.refreshBlink();
}
};
Terminal.prototype.startBlink = function() {
if (!this.cursorBlink) return;
this._blink = setInterval(this._cursorBlink.bind(this), 500);
};
Terminal.prototype.refreshBlink = function() {
if (!this.cursorBlink) return;
clearInterval(this._blink);
this._blink = setInterval(this._cursorBlink.bind(this), 500);
};
Terminal.prototype.scroll = function() {
var row;