fix scrolling animation
This commit is contained in:
parent
db264306c9
commit
7bff33c986
1 changed files with 6 additions and 5 deletions
|
|
@ -751,22 +751,22 @@ var VirtualRenderer = function(container, theme) {
|
||||||
return steps;
|
return steps;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.scrollToLine = function(line, center, animate) {
|
this.scrollToLine = function(line, center, animate, callback) {
|
||||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||||
var offset = pos.top;
|
var offset = pos.top;
|
||||||
if (center)
|
if (center)
|
||||||
offset -= this.$size.scrollerHeight / 2;
|
offset -= this.$size.scrollerHeight / 2;
|
||||||
|
|
||||||
if (animate) {
|
if (animate !== false) {
|
||||||
this.animateScrolling(function() {
|
this.animateScrolling(function() {
|
||||||
this.session.setScrollTop(offset);
|
this.session.setScrollTop(offset);
|
||||||
}, this);
|
}, this, callback);
|
||||||
} else {
|
} else {
|
||||||
this.session.setScrollTop(offset);
|
this.session.setScrollTop(offset);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.animateScrolling = function(scrollFunc, self) {
|
this.animateScrolling = function(scrollFunc, self, callback) {
|
||||||
var fromValue = this.scrollTop;
|
var fromValue = this.scrollTop;
|
||||||
scrollFunc.call(self);
|
scrollFunc.call(self);
|
||||||
var toValue = this.scrollTop;
|
var toValue = this.scrollTop;
|
||||||
|
|
@ -789,6 +789,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
_self.session.$scrollTop = -1;
|
_self.session.$scrollTop = -1;
|
||||||
_self.session.setScrollTop(toValue);
|
_self.session.setScrollTop(toValue);
|
||||||
|
callback && callback();
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue