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;
|
||||
};
|
||||
|
||||
this.scrollToLine = function(line, center, animate) {
|
||||
this.scrollToLine = function(line, center, animate, callback) {
|
||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||
var offset = pos.top;
|
||||
if (center)
|
||||
offset -= this.$size.scrollerHeight / 2;
|
||||
|
||||
if (animate) {
|
||||
if (animate !== false) {
|
||||
this.animateScrolling(function() {
|
||||
this.session.setScrollTop(offset);
|
||||
}, this);
|
||||
}, this, callback);
|
||||
} else {
|
||||
this.session.setScrollTop(offset);
|
||||
}
|
||||
};
|
||||
|
||||
this.animateScrolling = function(scrollFunc, self) {
|
||||
this.animateScrolling = function(scrollFunc, self, callback) {
|
||||
var fromValue = this.scrollTop;
|
||||
scrollFunc.call(self);
|
||||
var toValue = this.scrollTop;
|
||||
|
|
@ -778,7 +778,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
clearInterval(this.$timer);
|
||||
|
||||
_self.session.setScrollTop(steps.shift());
|
||||
this.$timer = setInterval(function() {
|
||||
this.$timer = setInterval(function() {
|
||||
if (steps.length) {
|
||||
_self.session.setScrollTop(steps.shift());
|
||||
// trick session to think it's already scrolled to not loose toValue
|
||||
|
|
@ -789,6 +789,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
_self.session.$scrollTop = -1;
|
||||
_self.session.setScrollTop(toValue);
|
||||
callback && callback();
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue