Expo easing functions

feature/coffeescript
Sven Slootweg 10 years ago
parent 85658ad24b
commit 7afceec382

@ -690,6 +690,9 @@
this.invert_repeat = invert_repeat;
this.next = next;
this.params = params;
this.expoInOut = __bind(this.expoInOut, this);
this.expoOut = __bind(this.expoOut, this);
this.expoIn = __bind(this.expoIn, this);
this.elasticInOut = __bind(this.elasticInOut, this);
this.elasticIn = __bind(this.elasticIn, this);
this.elasticOut = __bind(this.elasticOut, this);
@ -891,6 +894,23 @@
}
};
Ease.prototype.expoIn = function(time) {
return this.change * Math.pow(2, 10 * (time / this.duration - 1)) + this.start;
};
Ease.prototype.expoOut = function(time) {
return this.change * (-Math.pow(2, -10 * time / this.duration) + 1) + this.start;
};
Ease.prototype.expoInOut = function(time) {
time = time / (this.duration / 2);
if (time < 1) {
return this.change / 2 * Math.pow(2, 10 * (time - 1)) + this.start;
} else {
return this.change / 2 * (-Math.pow(2, -10 * (time - 1)) + 2) + this.start;
}
};
return Ease;
})();

@ -239,3 +239,18 @@ class Ease
return -0.5 * (amplitude * Math.pow(2, -10 * time)) * Math.sin((time * @duration - overshoot) * ((2 * Math.PI) / period)) + @start
else
return amplitude * Math.pow(2, -10 * time) * Math.sin((time * @duration - overshoot) * (2 * Math.PI) / period) + @change + @start
expoIn: (time) =>
return @change * Math.pow(2, 10 * (time / @duration - 1)) + @start
expoOut: (time) =>
return @change * (-Math.pow(2, -10 * time / @duration) + 1) + @start
expoInOut: (time) =>
time = time / (@duration / 2)
if time < 1
return @change / 2 * Math.pow(2, 10 * (time - 1)) + @start
else
return @change / 2 * (-Math.pow(2, -10 * (time - 1)) + 2) + @start

Loading…
Cancel
Save