VirtualRenderer: Fix buggy offset

This commit is contained in:
Julian Viereck 2011-01-09 11:20:00 +01:00
commit 2df81fffae

View file

@ -146,7 +146,6 @@ var VirtualRenderer = function(container, theme) {
* Triggers partial update of the text layer
*/
this.updateLines = function(firstRow, lastRow) {
console.log("updateLines", firstRow, lastRow);
if (lastRow === undefined)
lastRow = Infinity;
@ -399,17 +398,20 @@ var VirtualRenderer = function(container, theme) {
var lineCount = Math.ceil(minHeight / 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 - 1;
var lastRow = firstRow + lineCount;
// Add support for wrapped lines.
// Map lines on the screen to lines in the document.
var firstRowScreen, firstRowHeight;
var lineHeight = { lineHeight: this.lineHeight };
firstRow = this.doc.screenToDocumentRow(firstRow);
var firstRowScreen = this.doc.documentToScreenRow(firstRow);
lastRow = Math.min(this.doc.screenToDocumentRow(lastRow), this.doc.lines.length - 1);
offset = this.scrollTop % this.doc.getRowHeight(lineHeight, firstRow);
console.log("renderer.computeLayerConfig", firstRow, lastRow);
firstRowScreen = this.doc.documentToScreenRow(firstRow);
firstRowHeight = this.doc.getRowHeight(lineHeight, firstRow);
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 = {
width : longestLine,