VirtualRenderer: Fix buggy offset
This commit is contained in:
parent
8b6ba9f702
commit
2df81fffae
1 changed files with 10 additions and 8 deletions
|
|
@ -146,7 +146,6 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* Triggers partial update of the text layer
|
* Triggers partial update of the text layer
|
||||||
*/
|
*/
|
||||||
this.updateLines = function(firstRow, lastRow) {
|
this.updateLines = function(firstRow, lastRow) {
|
||||||
console.log("updateLines", firstRow, lastRow);
|
|
||||||
if (lastRow === undefined)
|
if (lastRow === undefined)
|
||||||
lastRow = Infinity;
|
lastRow = Infinity;
|
||||||
|
|
||||||
|
|
@ -399,17 +398,20 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
var lineCount = Math.ceil(minHeight / this.lineHeight);
|
var lineCount = Math.ceil(minHeight / this.lineHeight);
|
||||||
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
|
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
|
||||||
//var lastRow = Math.max(0, Math.min(this.lines.length, firstRow + lineCount) - 1);
|
var lastRow = firstRow + lineCount;
|
||||||
var lastRow = firstRow + lineCount - 1;
|
|
||||||
|
|
||||||
// Add support for wrapped lines.
|
// Map lines on the screen to lines in the document.
|
||||||
|
var firstRowScreen, firstRowHeight;
|
||||||
var lineHeight = { lineHeight: this.lineHeight };
|
var lineHeight = { lineHeight: this.lineHeight };
|
||||||
firstRow = this.doc.screenToDocumentRow(firstRow);
|
firstRow = this.doc.screenToDocumentRow(firstRow);
|
||||||
var firstRowScreen = this.doc.documentToScreenRow(firstRow);
|
firstRowScreen = this.doc.documentToScreenRow(firstRow);
|
||||||
lastRow = Math.min(this.doc.screenToDocumentRow(lastRow), this.doc.lines.length - 1);
|
firstRowHeight = this.doc.getRowHeight(lineHeight, firstRow);
|
||||||
offset = this.scrollTop % this.doc.getRowHeight(lineHeight, firstRow);
|
|
||||||
console.log("renderer.computeLayerConfig", firstRow, lastRow);
|
|
||||||
|
|
||||||
|
lastRow = Math.min(this.doc.screenToDocumentRow(lastRow), this.doc.lines.length - 1);
|
||||||
|
minHeight = this.$size.scrollerHeight + this.doc.getRowHeight(lineHeight, lastRow)+
|
||||||
|
firstRowHeight;
|
||||||
|
|
||||||
|
offset = this.scrollTop - firstRowScreen * this.lineHeight;
|
||||||
|
|
||||||
var layerConfig = this.layerConfig = {
|
var layerConfig = this.layerConfig = {
|
||||||
width : longestLine,
|
width : longestLine,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue