Browse Source

Cubic easing functions

feature/coffeescript
Sven Slootweg 8 years ago
parent
commit
ed13af354f
  1. 23
      compiled/radium.js
  2. 16
      radium/engine.ease.coffee

23
compiled/radium.js

@ -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;
})();

16
radium/engine.ease.coffee

@ -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