Skip to content

Commit 5d45a7f

Browse files
committed
Re-arrange lineCount calls
1 parent d8babb3 commit 5d45a7f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/scroller.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Scroller.prototype.setLines = function(newLines, offset) {
4545
this.lines = newLines;
4646
this.lineOffset = offset;
4747
if(this.sticky){
48-
this.startPosition = Math.max(this.lineOffset, this.lineCount() - this.visibleCount);
4948
this.endPosition = this.lineCount();
49+
this.startPosition = Math.max(this.lineOffset, this.endPosition - this.visibleCount);
5050
if(this.endPosition <= this.visibleCount){
5151
// follow text during initial 50 lines
5252
this.jumpToBottom = true;
@@ -71,8 +71,8 @@ Scroller.prototype.lineCount = function(){
7171
};
7272

7373
Scroller.prototype.reset = function(){
74-
this.startPosition = Math.max(0, this.lineCount() - this.visibleCount);
7574
this.endPosition = Math.max(0, this.lineCount());
75+
this.startPosition = Math.max(0, this.endPosition - this.visibleCount);
7676
this.lineOffset = 0;
7777
this.jumpToBottom = true;
7878
this.sticky = true;
@@ -90,8 +90,8 @@ Scroller.prototype._renderVisible = function(){
9090
if(this.dirty && this.console){
9191
const top = this.console.scrollTop;
9292
if(this.sticky){
93-
this.startPosition = Math.max(this.lineOffset, this.lineCount() - this.visibleCount);
9493
this.endPosition = this.lineCount();
94+
this.startPosition = Math.max(this.lineOffset, this.endPosition - this.visibleCount);
9595
}
9696
this.console.innerHTML = this._generateContent();
9797
if(this.jumpToBottom){

0 commit comments

Comments
 (0)