Store the top scroll top in the document
This commit is contained in:
parent
231d5e78de
commit
150ab68452
4 changed files with 19 additions and 1 deletions
|
|
@ -34,7 +34,6 @@
|
|||
#controls {
|
||||
width: 100%;
|
||||
height: 55px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -80,6 +80,18 @@ ace.Document.prototype.getMode = function() {
|
|||
return this._mode;
|
||||
};
|
||||
|
||||
ace.Document.prototype._scrollTop = 0;
|
||||
ace.Document.prototype.setScrollTopRow = function(scrollTopRow) {
|
||||
if (this._scrollTop === scrollTopRow) return;
|
||||
|
||||
this._scrollTop = scrollTopRow;
|
||||
this.$dispatchEvent("changeScrollTop");
|
||||
};
|
||||
|
||||
ace.Document.prototype.getScrollTopRow = function() {
|
||||
return this._scrollTop;
|
||||
};
|
||||
|
||||
ace.Document.prototype.getWidth = function() {
|
||||
if (this.modified) {
|
||||
this.modified = false;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ ace.Editor.prototype.setDocument = function(doc) {
|
|||
var selection = this.doc.getSelection();
|
||||
this.selection.removeEventListener("changeCursor", this._onCursorChange);
|
||||
this.selection.removeEventListener("changeSelection", this._onSelectionChange);
|
||||
|
||||
this.doc.setScrollTopRow(this.renderer.getScrollTopRow());
|
||||
}
|
||||
|
||||
this.doc = doc;
|
||||
|
|
@ -66,6 +68,7 @@ ace.Editor.prototype.setDocument = function(doc) {
|
|||
this.renderer.draw();
|
||||
this.onCursorChange();
|
||||
this.onSelectionChange();
|
||||
this.renderer.scrollToRow(doc.getScrollTopRow());
|
||||
};
|
||||
|
||||
ace.Editor.prototype.getDocument = function() {
|
||||
|
|
|
|||
|
|
@ -198,6 +198,10 @@ ace.VirtualRenderer.prototype.getScrollTop = function() {
|
|||
return this.scrollTop;
|
||||
};
|
||||
|
||||
ace.VirtualRenderer.prototype.getScrollTopRow = function() {
|
||||
return this.scrollTop / this.lineHeight;
|
||||
};
|
||||
|
||||
ace.VirtualRenderer.prototype.scrollToRow = function(row) {
|
||||
this.scrollToY(row * this.lineHeight);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue