eliminate scrollbar jitter while typing at the bottom of screen
This commit is contained in:
parent
6464a3852b
commit
64a55719b2
1 changed files with 12 additions and 8 deletions
|
|
@ -95,7 +95,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.scrollBar = new ScrollBar(container);
|
||||
this.scrollBar.addEventListener("scroll", this.onScroll.bind(this));
|
||||
|
||||
this.scrollTop = 0;
|
||||
this.scrollTop = this.desiredScrollTop = 0;
|
||||
|
||||
this.cursorPos = {
|
||||
row : 0,
|
||||
|
|
@ -384,7 +384,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.$updateScrollBar = function() {
|
||||
this.scrollBar.setInnerHeight(this.session.getScreenLength() * this.lineHeight);
|
||||
this.scrollBar.setInnerHeight(this.layerConfig.maxHeight);
|
||||
this.scrollBar.setScrollTop(this.scrollTop);
|
||||
};
|
||||
|
||||
|
|
@ -469,6 +469,10 @@ var VirtualRenderer = function(container, theme) {
|
|||
if (horizScrollChanged)
|
||||
this.scroller.style.overflowX = horizScroll ? "scroll" : "hidden";
|
||||
|
||||
var maxHeight = this.session.getScreenLength() * this.lineHeight;
|
||||
this.scrollTop = this.desiredScrollTop =
|
||||
Math.max(0, Math.min(this.desiredScrollTop, maxHeight - this.$size.scrollerHeight));
|
||||
|
||||
var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
|
||||
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
|
||||
var lastRow = firstRow + lineCount;
|
||||
|
|
@ -494,7 +498,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
offset = this.scrollTop - firstRowScreen * this.lineHeight;
|
||||
|
||||
var layerConfig = this.layerConfig = {
|
||||
this.layerConfig = {
|
||||
width : longestLine,
|
||||
padding : this.$padding,
|
||||
firstRow : firstRow,
|
||||
|
|
@ -503,12 +507,13 @@ var VirtualRenderer = function(container, theme) {
|
|||
lineHeight : this.lineHeight,
|
||||
characterWidth : this.characterWidth,
|
||||
minHeight : minHeight,
|
||||
maxHeight : maxHeight,
|
||||
offset : offset,
|
||||
height : this.$size.scrollerHeight
|
||||
};
|
||||
|
||||
// For debugging.
|
||||
// console.log(JSON.stringify(layerConfig));
|
||||
// console.log(JSON.stringify(this.layerConfig));
|
||||
|
||||
this.$gutterLayer.element.style.marginTop = (-offset) + "px";
|
||||
this.content.style.marginTop = (-offset) + "px";
|
||||
|
|
@ -662,12 +667,11 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.scrollToY = function(scrollTop) {
|
||||
var maxHeight = this.session.getScreenLength() * this.lineHeight - this.$size.scrollerHeight;
|
||||
var scrollTop = Math.max(0, Math.min(maxHeight, scrollTop));
|
||||
|
||||
// after calling scrollBar.setScrollTop
|
||||
// scrollbar sends us event with same scrollTop. ignore it
|
||||
if (this.scrollTop !== scrollTop) {
|
||||
this.scrollTop = scrollTop;
|
||||
this.$loop.schedule(this.CHANGE_SCROLL);
|
||||
this.desiredScrollTop = scrollTop;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue