update "scrollbarWidth()" function to work in IE
This commit is contained in:
parent
a02b64c510
commit
b5679cb6b6
1 changed files with 23 additions and 8 deletions
31
src/ace.js
31
src/ace.js
|
|
@ -120,20 +120,35 @@ ace.computedStyle = function(element, style) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ace.scrollbarWidth = function(parent) {
|
ace.scrollbarWidth = function() {
|
||||||
var el = document.createElement("div");
|
|
||||||
var style = el.style;
|
var inner = document.createElement('p');
|
||||||
|
inner.style.width = "100%";
|
||||||
|
inner.style.height = "200px";
|
||||||
|
|
||||||
|
var outer = document.createElement("div");
|
||||||
|
var style = outer.style;
|
||||||
|
|
||||||
style.position = "absolute";
|
style.position = "absolute";
|
||||||
style.left = "-10000px";
|
style.left = "-10000px";
|
||||||
|
style.overflow = "hidden";
|
||||||
|
style.width = "200px";
|
||||||
|
style.height = "150px";
|
||||||
|
|
||||||
|
outer.appendChild(inner);
|
||||||
|
document.body.appendChild(outer);
|
||||||
|
var noScrollbar = inner.offsetWidth;
|
||||||
|
|
||||||
style.overflow = "scroll";
|
style.overflow = "scroll";
|
||||||
style.width = "100px";
|
var withScrollbar = inner.offsetWidth;
|
||||||
|
|
||||||
(parent || document.body).appendChild(el);
|
if (noScrollbar == withScrollbar) {
|
||||||
var width = el.offsetWidth - el.clientWidth;
|
withScrollbar = outer.clientWidth;
|
||||||
document.body.removeChild(el);
|
}
|
||||||
|
|
||||||
return width;
|
document.body.removeChild(outer);
|
||||||
|
|
||||||
|
return noScrollbar-withScrollbar;
|
||||||
};
|
};
|
||||||
|
|
||||||
ace.stringReverse = function(string) {
|
ace.stringReverse = function(string) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue