bounce.js 521 B

12345678910111213141516171819202122
  1. var b1 = 4 / 11,
  2. b2 = 6 / 11,
  3. b3 = 8 / 11,
  4. b4 = 3 / 4,
  5. b5 = 9 / 11,
  6. b6 = 10 / 11,
  7. b7 = 15 / 16,
  8. b8 = 21 / 22,
  9. b9 = 63 / 64,
  10. b0 = 1 / b1 / b1;
  11. export function bounceIn(t) {
  12. return 1 - bounceOut(1 - t);
  13. }
  14. export function bounceOut(t) {
  15. return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
  16. }
  17. export function bounceInOut(t) {
  18. return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
  19. }