fix editor scrolling down automatically when resizing and scrolled past end

This commit is contained in:
nightwing 2014-05-04 17:32:12 +04:00
commit ee4bed3db1

View file

@ -337,8 +337,6 @@ var VirtualRenderer = function(container, theme) {
* *
**/ **/
this.onResize = function(force, gutterWidth, width, height) { this.onResize = function(force, gutterWidth, width, height) {
// if (force)
// console.log("force resize requested", width, height)
if (this.resizing > 2) if (this.resizing > 2)
return; return;
else if (this.resizing > 0) else if (this.resizing > 0)
@ -354,12 +352,6 @@ var VirtualRenderer = function(container, theme) {
width = el.clientWidth || el.scrollWidth; width = el.clientWidth || el.scrollWidth;
var changes = this.$updateCachedSize(force, gutterWidth, width, height); var changes = this.$updateCachedSize(force, gutterWidth, width, height);
// console.log("resizing to", width, height, JSON.stringify(this.$size))
// setTimeout(function() {
// console.log("actual size ", this.container.clientWidth, this.container.clientHeight)
// }.bind(this), 500)
if (!this.$size.scrollerHeight || (!width && !height)) if (!this.$size.scrollerHeight || (!width && !height))
return this.resizing = 0; return this.resizing = 0;
@ -757,7 +749,16 @@ var VirtualRenderer = function(container, theme) {
}; };
this.$updateScrollBarV = function() { this.$updateScrollBarV = function() {
this.scrollBarV.setScrollHeight(this.layerConfig.maxHeight + this.scrollMargin.v); var scrollHeight = this.layerConfig.maxHeight;
var scrollerHeight = this.$size.scrollerHeight;
if (!this.$maxLines && this.$scrollPastEnd) {
scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
if (this.scrollTop > scrollHeight - scrollerHeight) {
scrollHeight = this.scrollTop + scrollerHeight;
this.scrollBarV.scrollTop = null;
}
}
this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top); this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
}; };
this.$updateScrollBarH = function() { this.$updateScrollBarH = function() {
@ -934,11 +935,7 @@ var VirtualRenderer = function(container, theme) {
} }
if (!this.$maxLines && this.$scrollPastEnd) { if (!this.$maxLines && this.$scrollPastEnd) {
if (this.scrollTop > maxHeight - size.scrollerHeight) maxHeight += (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
maxHeight += Math.min(
(size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd,
this.scrollTop - maxHeight + size.scrollerHeight
);
} }
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible || var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
@ -1373,8 +1370,7 @@ var VirtualRenderer = function(container, theme) {
if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top) if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
return true; return true;
if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
- this.layerConfig.maxHeight - (this.$size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
< -1 + this.scrollMargin.bottom)
return true; return true;
if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left) if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
return true; return true;