* Tweaked scroll animations
* Added animations to pgup/pgdn goto start/end of document
This commit is contained in:
parent
54b1f3f9ac
commit
ac70ecc005
2 changed files with 56 additions and 31 deletions
|
|
@ -733,16 +733,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.session.setScrollTop(row * this.lineHeight);
|
||||
};
|
||||
|
||||
this.STEPS = 10;
|
||||
this.STEPS = 7;
|
||||
this.$calcSteps = function(fromValue, toValue){
|
||||
var i = 0;
|
||||
var l = this.STEPS;
|
||||
var steps = [];
|
||||
|
||||
var func = function(t, x_min, dx) {
|
||||
if ((t /= .5) < 1)
|
||||
return dx / 2 * Math.pow(t, 3) + x_min;
|
||||
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
||||
return dx * (Math.pow(t - 1, 3) + 1) + x_min;
|
||||
};
|
||||
|
||||
for (i = 0; i < l; ++i)
|
||||
|
|
@ -752,13 +750,14 @@ var VirtualRenderer = function(container, theme) {
|
|||
return steps;
|
||||
};
|
||||
|
||||
this.scrollToLine = function(line, center) {
|
||||
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 (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 100000) {
|
||||
if (animate !== false
|
||||
&& this.$animatedScroll && Math.abs(offset - this.scrollTop) < 100000) {
|
||||
var _self = this;
|
||||
var steps = _self.$calcSteps(this.scrollTop, offset);
|
||||
|
||||
|
|
@ -766,8 +765,10 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$timer = setInterval(function() {
|
||||
_self.session.setScrollTop(steps.shift());
|
||||
|
||||
if (!steps.length)
|
||||
if (!steps.length) {
|
||||
callback && callback();
|
||||
clearInterval(_self.$timer);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue