Skip to content

Commit 695912d

Browse files
committed
Smooth transition from sticky/backscroll and prevent scroll hitting top before exhausting console
1 parent 6b53a09 commit 695912d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

plugins/editor/scroller.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Scroller.prototype.requestRefresh = function(){
7575
};
7676

7777
Scroller.prototype._renderVisible = function(){
78+
var top = this.console.scrollTop;
7879
this.animateRequest = null;
7980
if(this.dirty && this.console){
8081
if(this.sticky){
@@ -84,6 +85,9 @@ Scroller.prototype._renderVisible = function(){
8485
if(this.jumpToBottom){
8586
this.console.scrollTop = 350000;
8687
this.jumpToBottom = false;
88+
}else if(!this.sticky && this.startPosition > 0 && top === 0){
89+
//cover the situation where the window was fully scrolled faster than expand could keep up and locked to the top
90+
this.console.scrollTop = 1;
8791
}
8892
this.dirty = false;
8993
}
@@ -111,13 +115,15 @@ Scroller.prototype._onScroll = function(){
111115
var scrollTop = this.console.scrollTop;
112116
if(!this.jumpToBottom && scrollTop < 15 && this.startPosition > 0){
113117
this.expand();
114-
}else if(!this.sticky && scrollTop + height > scrollHeight - 15){
118+
}else if(!this.sticky && scrollTop + height > scrollHeight - 20){
115119
this.jumpToBottom = true;
116120
this.sticky = true;
117121
this.dirty = true;
122+
}else if(this.sticky && scrollTop + height < scrollHeight - 40){
123+
this.sticky = false;
118124
}
119125

120-
if(this.dirty){
126+
if(this.dirty && !this.animateRequest){
121127
this.animateRequest = requestAnimationFrame(this.refresh);
122128
}
123129
};

0 commit comments

Comments
 (0)