Permalink
Browse files

Blink Cursor with CSS3 animations

  • Loading branch information...
icebeat committed May 22, 2012
1 parent 2acedc9 commit b9801131284479fed8a7425ca7b01060f95e6f53
Showing with 12 additions and 10 deletions.
  1. +6 −0 css.css
  2. +6 −9 js/cursor.js
  3. +0 −1 js/editor.js
View
@@ -101,6 +101,12 @@ body { overflow: auto; }
top: -32px;
left: 0;
z-index: 15;
+ -webkit-animation: blink-cursor 1.2s step-end infinite;
+ }
+
+ @-webkit-keyframes blink-cursor {
+ from, to { background-color: #00BAFF; }
+ 50% { background-color: transparent; }
}
/* Selection */
View
@@ -4,19 +4,16 @@ Cursor.js
*/
Extend(Editor.prototype, {
- blinkCursor: function (toggle) {
- clearInterval(this.blinker);
- if (toggle===false) return;
- var on = true, cursor = this.element.cursor.style;
- cursor.visibility = "";
- this.blinker = setInterval(function () {
- cursor.visibility = (on = !on) ? "" : "hidden";
- }, 650);
+ blinkCursor: function () {
+ var cursor = this.element.cursor.style;
+ cursor.webkitAnimationName = "none";
+ setTimeout(function () {
+ cursor.webkitAnimationName = "";
+ }, 10);
},
hideCursor: function () {
this.element.cursor.style.display = "none";
- this.blinkCursor(false);
},
updateCursor: function (from, to) {
this.setCursor(to.x, to.y);
View
@@ -20,7 +20,6 @@ var Editor = function (lines, options) {
this.lastDoubleClick = null;
this.lastClick = null;
this.focusmode = null;
- this.blinker = null;
this.shiftSelecting = null;
this.textSelected = null;
this.textPasted = null;

0 comments on commit b980113

Please sign in to comment.