coding styles

This commit is contained in:
Fabian Jakobs 2012-04-11 17:19:56 +02:00
commit 2208ccdd48

View file

@ -725,25 +725,24 @@ var VirtualRenderer = function(container, theme) {
this.session.setScrollTop(row * this.lineHeight);
};
//@todo I would like to make this animation a setting. How?
var STEPS = 10;
function calcSteps(fromValue, toValue){
var i = 0,
l = STEPS,
steps = [],
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;
};
this.STEPS = 10;
this.$calcSteps = function(fromValue, toValue){
var i = 0;
var l = 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;
};
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);
return steps;
}
};
this.scrollToLine = function(line, center) {
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
@ -752,10 +751,12 @@ var VirtualRenderer = function(container, theme) {
offset -= this.$size.scrollerHeight / 2;
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
var i = 0, _self = this,
steps = calcSteps(this.scrollTop, offset);
var i = 0;
var _self = this;
var steps = _self.$calcSteps(this.scrollTop, offset);
clearInterval(_self.$timer);
this.$timer = setInterval(function(){
this.$timer = setInterval(function() {
_self.session.setScrollTop(steps[i]);
if (++i == STEPS + 1)