Cubic easing functions

feature/coffeescript
Sven Slootweg 10 years ago
parent 24c6e785a1
commit ed13af354f

@ -691,6 +691,9 @@
this.invert_repeat = invert_repeat;
this.next = next;
this.params = params;
this.cubicInOut = __bind(this.cubicInOut, this);
this.cubicOut = __bind(this.cubicOut, this);
this.cubicIn = __bind(this.cubicIn, this);
this.circInOut = __bind(this.circInOut, this);
this.circOut = __bind(this.circOut, this);
this.circIn = __bind(this.circIn, this);
@ -835,6 +838,26 @@
}
};
Ease.prototype.cubicIn = function(time) {
time = time / this.duration;
return this.change * time * time * time + this.start;
};
Ease.prototype.cubicOut = function(time) {
time = time / this.duration - 1;
return this.change * (time * time * time + 1) + this.start;
};
Ease.prototype.cubicInOut = function(time) {
time = time / (duration / 2);
if (time < 1) {
return change / 2 * time * time * time + this.start;
} else {
time = time - 2;
return change / 2 * (time * time * time + 2) + begin;
}
};
return Ease;
})();

@ -197,3 +197,19 @@ class Ease
else
time = time - 2
return @change / 2 * (Math.sqrt(1 - time * time) + 1) + @start
cubicIn: (time) =>
time = time / @duration
return @change * time * time * time + @start
cubicOut: (time) =>
time = time / @duration - 1
return @change * (time * time * time + 1) + @start
cubicInOut: (time) =>
time = time / (duration / 2)
if time < 1
return change / 2 * time * time * time + @start
else
time = time - 2
return change / 2 * (time * time * time + 2) + begin

Loading…
Cancel
Save