coding styles
This commit is contained in:
parent
ec061ff303
commit
2208ccdd48
1 changed files with 18 additions and 17 deletions
|
|
@ -725,25 +725,24 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.session.setScrollTop(row * this.lineHeight);
|
this.session.setScrollTop(row * this.lineHeight);
|
||||||
};
|
};
|
||||||
|
|
||||||
//@todo I would like to make this animation a setting. How?
|
this.STEPS = 10;
|
||||||
|
this.$calcSteps = function(fromValue, toValue){
|
||||||
|
var i = 0;
|
||||||
|
var l = STEPS;
|
||||||
|
var steps = [];
|
||||||
|
|
||||||
var STEPS = 10;
|
var func = function(t, x_min, dx) {
|
||||||
function calcSteps(fromValue, toValue){
|
|
||||||
var i = 0,
|
|
||||||
l = STEPS,
|
|
||||||
steps = [],
|
|
||||||
func = function(t, x_min, dx) {
|
|
||||||
if ((t /= .5) < 1)
|
if ((t /= .5) < 1)
|
||||||
return dx / 2 * Math.pow(t, 3) + x_min;
|
return dx / 2 * Math.pow(t, 3) + x_min;
|
||||||
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
return dx / 2 * (Math.pow(t - 2, 3) + 2) + x_min;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < l; ++i)
|
for (i = 0; i < l; ++i)
|
||||||
steps.push(func(i / STEPS, fromValue, toValue - fromValue));
|
steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
|
||||||
steps.push(toValue);
|
steps.push(toValue);
|
||||||
|
|
||||||
return steps;
|
return steps;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.scrollToLine = function(line, center) {
|
this.scrollToLine = function(line, center) {
|
||||||
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
|
||||||
|
|
@ -752,8 +751,10 @@ var VirtualRenderer = function(container, theme) {
|
||||||
offset -= this.$size.scrollerHeight / 2;
|
offset -= this.$size.scrollerHeight / 2;
|
||||||
|
|
||||||
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
|
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
|
||||||
var i = 0, _self = this,
|
var i = 0;
|
||||||
steps = calcSteps(this.scrollTop, offset);
|
var _self = this;
|
||||||
|
var steps = _self.$calcSteps(this.scrollTop, offset);
|
||||||
|
|
||||||
clearInterval(_self.$timer);
|
clearInterval(_self.$timer);
|
||||||
this.$timer = setInterval(function() {
|
this.$timer = setInterval(function() {
|
||||||
_self.session.setScrollTop(steps[i]);
|
_self.session.setScrollTop(steps[i]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue