* Added ability to force ace to resize
* Automatically size the width via css
This commit is contained in:
parent
f4b5a13855
commit
d9c0212fa1
3 changed files with 32 additions and 11 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
.ace_scroller {
|
.ace_scroller {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
width : 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace_content {
|
.ace_content {
|
||||||
|
|
|
||||||
|
|
@ -249,8 +249,8 @@ var Editor = function(renderer, session) {
|
||||||
*
|
*
|
||||||
* {:VirtualRenderer.onResize}
|
* {:VirtualRenderer.onResize}
|
||||||
**/
|
**/
|
||||||
this.resize = function() {
|
this.resize = function(force) {
|
||||||
this.renderer.onResize();
|
this.renderer.onResize(force);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -264,8 +264,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
*
|
*
|
||||||
* Triggers a full update of all the layers, for all the rows.
|
* Triggers a full update of all the layers, for all the rows.
|
||||||
**/
|
**/
|
||||||
this.updateFull = function() {
|
this.updateFull = function(force) {
|
||||||
this.$loop.schedule(this.CHANGE_FULL);
|
if (force){
|
||||||
|
this.$renderChanges(this.CHANGE_FULL, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.$loop.schedule(this.CHANGE_FULL);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -283,11 +288,19 @@ var VirtualRenderer = function(container, theme) {
|
||||||
*
|
*
|
||||||
* [Triggers a resize of the editor.]{: #VirtualRenderer.onResize}
|
* [Triggers a resize of the editor.]{: #VirtualRenderer.onResize}
|
||||||
**/
|
**/
|
||||||
this.onResize = function(force) {
|
this.onResize = function(force, gutterWidth, width, height) {
|
||||||
var changes = this.CHANGE_SIZE;
|
var changes = this.CHANGE_SIZE;
|
||||||
var size = this.$size;
|
var size = this.$size;
|
||||||
|
|
||||||
var height = dom.getInnerHeight(this.container);
|
if (this.resizing) {
|
||||||
|
force = 2;
|
||||||
|
height = size.height;
|
||||||
|
width = size.width;
|
||||||
|
}
|
||||||
|
this.resizing = force;
|
||||||
|
|
||||||
|
if (!height)
|
||||||
|
height = dom.getInnerHeight(this.container);
|
||||||
if (force || size.height != height) {
|
if (force || size.height != height) {
|
||||||
size.height = height;
|
size.height = height;
|
||||||
|
|
||||||
|
|
@ -301,20 +314,27 @@ var VirtualRenderer = function(container, theme) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var width = dom.getInnerWidth(this.container);
|
if (!width)
|
||||||
|
width = dom.getInnerWidth(this.container);
|
||||||
if (force || size.width != width) {
|
if (force || size.width != width) {
|
||||||
size.width = width;
|
size.width = width;
|
||||||
|
|
||||||
var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
|
var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
|
||||||
this.scroller.style.left = gutterWidth + "px";
|
this.scroller.style.left = gutterWidth + "px";
|
||||||
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
|
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
|
||||||
this.scroller.style.width = size.scrollerWidth + "px";
|
//this.scroller.style.width = size.scrollerWidth + "px";
|
||||||
|
|
||||||
if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
|
if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
|
||||||
changes = changes | this.CHANGE_FULL;
|
changes = changes | this.CHANGE_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$loop.schedule(changes);
|
if (force || this.resizing)
|
||||||
|
this.$renderChanges(changes, true);
|
||||||
|
else
|
||||||
|
this.$loop.schedule(changes);
|
||||||
|
|
||||||
|
if (force === true)
|
||||||
|
delete this.resizing;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -630,8 +650,8 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.scrollBar.setScrollTop(this.scrollTop);
|
this.scrollBar.setScrollTop(this.scrollTop);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$renderChanges = function(changes) {
|
this.$renderChanges = function(changes, force) {
|
||||||
if (!changes || !this.session || !this.container.offsetWidth)
|
if (!force && (!changes || !this.session || !this.container.offsetWidth))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// text, scrolling and resize changes can cause the view port size to change
|
// text, scrolling and resize changes can cause the view port size to change
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue