remove slow cursor[style*] css rule
This commit is contained in:
parent
5e2c5f4e0a
commit
048d9589c7
2 changed files with 39 additions and 22 deletions
|
|
@ -63,6 +63,10 @@
|
||||||
left: 0;
|
left: 0;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
|
-ms-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace_gutter-active-line {
|
.ace_gutter-active-line {
|
||||||
|
|
@ -227,10 +231,6 @@
|
||||||
transition: opacity 0.18s;
|
transition: opacity 0.18s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace_cursor[style*="opacity: 0"]{
|
|
||||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_editor.ace_multiselect .ace_cursor {
|
.ace_editor.ace_multiselect .ace_cursor {
|
||||||
border-left-width: 1px;
|
border-left-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,15 @@ define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("../lib/dom");
|
||||||
|
var IE8;
|
||||||
|
|
||||||
var Cursor = function(parentEl) {
|
var Cursor = function(parentEl) {
|
||||||
this.element = dom.createElement("div");
|
this.element = dom.createElement("div");
|
||||||
this.element.className = "ace_layer ace_cursor-layer";
|
this.element.className = "ace_layer ace_cursor-layer";
|
||||||
parentEl.appendChild(this.element);
|
parentEl.appendChild(this.element);
|
||||||
|
|
||||||
|
if (IE8 === undefined)
|
||||||
|
IE8 = "opacity" in this.element;
|
||||||
|
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
this.isBlinking = true;
|
this.isBlinking = true;
|
||||||
|
|
@ -46,9 +50,22 @@ var Cursor = function(parentEl) {
|
||||||
this.cursors = [];
|
this.cursors = [];
|
||||||
this.cursor = this.addCursor();
|
this.cursor = this.addCursor();
|
||||||
dom.addCssClass(this.element, "ace_hidden-cursors");
|
dom.addCssClass(this.element, "ace_hidden-cursors");
|
||||||
|
this.$updateCursors = this.$updateVisibility.bind(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
this.$updateVisibility = function(val) {
|
||||||
|
var cursors = this.cursors;
|
||||||
|
for (var i = cursors.length; i--; )
|
||||||
|
cursors[i].style.visibility = val ? "" : "hidden";
|
||||||
|
};
|
||||||
|
this.$updateOpacity = function(val) {
|
||||||
|
var cursors = this.cursors;
|
||||||
|
for (var i = cursors.length; i--; )
|
||||||
|
cursors[i].style.opacity = val ? "" : "0";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.$padding = 0;
|
this.$padding = 0;
|
||||||
this.setPadding = function(padding) {
|
this.setPadding = function(padding) {
|
||||||
|
|
@ -74,12 +91,13 @@ var Cursor = function(parentEl) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setSmoothBlinking = function(smoothBlinking) {
|
this.setSmoothBlinking = function(smoothBlinking) {
|
||||||
if (smoothBlinking != this.smoothBlinking) {
|
if (smoothBlinking != this.smoothBlinking && !IE8) {
|
||||||
this.smoothBlinking = smoothBlinking;
|
this.smoothBlinking = smoothBlinking;
|
||||||
if (smoothBlinking)
|
dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
|
||||||
dom.addCssClass(this.element, "ace_smooth-blinking");
|
this.$updateCursors(true);
|
||||||
else
|
this.$updateCursors = (smoothBlinking
|
||||||
dom.removeCssClass(this.element, "ace_smooth-blinking");
|
? this.$updateOpacity
|
||||||
|
: this.$updateVisibility).bind(this);
|
||||||
this.restartTimer();
|
this.restartTimer();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -113,35 +131,34 @@ var Cursor = function(parentEl) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.restartTimer = function() {
|
this.restartTimer = function() {
|
||||||
|
var update = this.$updateCursors;
|
||||||
clearInterval(this.intervalId);
|
clearInterval(this.intervalId);
|
||||||
clearTimeout(this.timeoutId);
|
clearTimeout(this.timeoutId);
|
||||||
if (this.smoothBlinking)
|
if (this.smoothBlinking) {
|
||||||
dom.removeCssClass(this.element, "ace_smooth-blinking");
|
dom.removeCssClass(this.element, "ace_smooth-blinking");
|
||||||
for (var i = this.cursors.length; i--; )
|
}
|
||||||
this.cursors[i].style.opacity = "";
|
|
||||||
|
update(true);
|
||||||
|
|
||||||
if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
|
if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.smoothBlinking)
|
if (this.smoothBlinking) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
dom.addCssClass(this.element, "ace_smooth-blinking");
|
dom.addCssClass(this.element, "ace_smooth-blinking");
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
var blink = function(){
|
var blink = function(){
|
||||||
this.timeoutId = setTimeout(function() {
|
this.timeoutId = setTimeout(function() {
|
||||||
for (var i = this.cursors.length; i--; ) {
|
update(false);
|
||||||
this.cursors[i].style.opacity = 0;
|
}, 0.6 * this.blinkInterval);
|
||||||
}
|
|
||||||
}.bind(this), 0.6 * this.blinkInterval);
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.intervalId = setInterval(function() {
|
this.intervalId = setInterval(function() {
|
||||||
for (var i = this.cursors.length; i--; ) {
|
update(true);
|
||||||
this.cursors[i].style.opacity = "";
|
|
||||||
}
|
|
||||||
blink();
|
blink();
|
||||||
}.bind(this), this.blinkInterval);
|
}, this.blinkInterval);
|
||||||
|
|
||||||
blink();
|
blink();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue