add virtualRenderer.$updateSizeAsync
This commit is contained in:
parent
5607fc9de2
commit
f1973e4233
1 changed files with 24 additions and 8 deletions
|
|
@ -134,7 +134,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
width: 0,
|
||||
height: 0,
|
||||
scrollerHeight: 0,
|
||||
scrollerWidth: 0
|
||||
scrollerWidth: 0,
|
||||
$dirty: true
|
||||
};
|
||||
|
||||
this.layerConfig = {
|
||||
|
|
@ -223,6 +224,9 @@ var VirtualRenderer = function(container, theme) {
|
|||
**/
|
||||
this.setSession = function(session) {
|
||||
this.session = session;
|
||||
|
||||
if (this.scrollMargin.top && session.getScrollTop() <= 0)
|
||||
session.setScrollTop(-this.scrollMargin.top);
|
||||
|
||||
this.scroller.className = "ace_scroller";
|
||||
|
||||
|
|
@ -232,7 +236,6 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$gutterLayer.setSession(session);
|
||||
this.$textLayer.setSession(session);
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -300,6 +303,12 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.$changes = 0;
|
||||
this.$updateSizeAsync = function() {
|
||||
if (this.$loop.pending)
|
||||
this.$size.$dirty = true;
|
||||
else
|
||||
this.onResize();
|
||||
};
|
||||
/**
|
||||
* [Triggers a resize of the editor.]{: #VirtualRenderer.onResize}
|
||||
* @param {Boolean} force If `true`, recomputes the size, even if the height and width haven't changed
|
||||
|
|
@ -325,7 +334,6 @@ var VirtualRenderer = function(container, theme) {
|
|||
height = el.clientHeight || el.scrollHeight;
|
||||
if (!width)
|
||||
width = el.clientWidth || el.scrollWidth;
|
||||
|
||||
var changes = this.$updateCachedSize(force, gutterWidth, width, height);
|
||||
|
||||
// console.log("resizing to", width, height, JSON.stringify(this.$size))
|
||||
|
|
@ -342,7 +350,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$gutterLayer.$padding = null;
|
||||
|
||||
if (force)
|
||||
this.$renderChanges(changes, true);
|
||||
this.$renderChanges(changes | this.$changes, true);
|
||||
else
|
||||
this.$loop.schedule(changes | this.$changes);
|
||||
|
||||
|
|
@ -371,7 +379,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
|
||||
|
||||
if (this.session) {
|
||||
this.session.setScrollTop(this.getScrollTop());
|
||||
//this.session.setScrollTop(this.getScrollTop());
|
||||
changes = changes | this.CHANGE_SCROLL;
|
||||
}
|
||||
}
|
||||
|
|
@ -399,6 +407,9 @@ var VirtualRenderer = function(container, theme) {
|
|||
changes = changes | this.CHANGE_FULL;
|
||||
}
|
||||
|
||||
if (size.$dirty)
|
||||
size.$dirty = !width && !height;
|
||||
|
||||
if (changes)
|
||||
this._signal("resize", oldSize);
|
||||
|
||||
|
|
@ -410,9 +421,11 @@ var VirtualRenderer = function(container, theme) {
|
|||
if (gutterWidth != this.gutterWidth)
|
||||
this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
|
||||
|
||||
if (this.session.getUseWrapMode() && this.adjustWrapLimit())
|
||||
if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
else {
|
||||
} else if (this.$size.$dirty) {
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
} else {
|
||||
this.$computeLayerConfig();
|
||||
this.$loop.schedule(this.CHANGE_MARKER);
|
||||
}
|
||||
|
|
@ -692,6 +705,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
sm.left = left|0;
|
||||
sm.v = sm.top + sm.bottom;
|
||||
sm.h = sm.left + sm.right;
|
||||
if (sm.top && this.scrollTop <= 0 && this.session)
|
||||
this.session.setScrollTop(sm.top);
|
||||
this.updateFull();
|
||||
};
|
||||
|
||||
|
|
@ -744,7 +759,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$changes |= changes;
|
||||
return;
|
||||
}
|
||||
if (!this.$size.width) {
|
||||
if (this.$size.$dirty) {
|
||||
this.$changes |= changes;
|
||||
return this.onResize(true);
|
||||
}
|
||||
|
|
@ -972,6 +987,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.content.style.height = minHeight + "px";
|
||||
|
||||
return changes;
|
||||
return changes;
|
||||
};
|
||||
|
||||
this.$updateLines = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue