Advertisement
Guest User

eases

a guest
Oct 18th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Ease = {
  2.     inQuad: function (t, b, c, d) {
  3.         return c*(t/=d)*t + b;
  4.     },
  5.     outQuad: function (t, b, c, d) {
  6.         return -c *(t/=d)*(t-2) + b;
  7.     },
  8.     inOutQuad: function (t, b, c, d) {
  9.         if ((t/=d/2) < 1) return c/2*t*t + b;
  10.         return -c/2 * ((--t)*(t-2) - 1) + b;
  11.     },
  12.     inCubic: function (t, b, c, d) {
  13.         return c*(t/=d)*t*t + b;
  14.     },
  15.     outCubic: function (t, b, c, d) {
  16.         return c*((t=t/d-1)*t*t + 1) + b;
  17.     },
  18.     inOutCubic: function (t, b, c, d) {
  19.         if ((t/=d/2) < 1) return c/2*t*t*t + b;
  20.         return c/2*((t-=2)*t*t + 2) + b;
  21.     },
  22.     inQuart: function (t, b, c, d) {
  23.         return c*(t/=d)*t*t*t + b;
  24.     },
  25.     outQuart: function (t, b, c, d) {
  26.         return -c * ((t=t/d-1)*t*t*t - 1) + b;
  27.     },
  28.     inOutQuart: function (t, b, c, d) {
  29.         if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
  30.         return -c/2 * ((t-=2)*t*t*t - 2) + b;
  31.     },
  32.     inQuint: function (t, b, c, d) {
  33.         return c*(t/=d)*t*t*t*t + b;
  34.     },
  35.     outQuint: function (t, b, c, d) {
  36.         return c*((t=t/d-1)*t*t*t*t + 1) + b;
  37.     },
  38.     inOutQuint: function (t, b, c, d) {
  39.         if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
  40.         return c/2*((t-=2)*t*t*t*t + 2) + b;
  41.     },
  42.     inSine: function (t, b, c, d) {
  43.         return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
  44.     },
  45.     outSine: function (t, b, c, d) {
  46.         return c * Math.sin(t/d * (Math.PI/2)) + b;
  47.     },
  48.     inOutSine: function (t, b, c, d) {
  49.         return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
  50.     },
  51.     inExpo: function (t, b, c, d) {
  52.         return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
  53.     },
  54.     outExpo: function (t, b, c, d) {
  55.         return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  56.     },
  57.     inOutExpo: function (t, b, c, d) {
  58.         if (t==0) return b;
  59.         if (t==d) return b+c;
  60.         if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
  61.         return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
  62.     },
  63.     inCirc: function (t, b, c, d) {
  64.         return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
  65.     },
  66.     outCirc: function (t, b, c, d) {
  67.         return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
  68.     },
  69.     inOutCirc: function (t, b, c, d) {
  70.         if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
  71.         return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
  72.     },
  73.     inElastic: function (t, b, c, d) {
  74.         var s=1.70158;var p=0;var a=c;
  75.         if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
  76.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  77.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  78.         return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  79.     },
  80.     outElastic: function (t, b, c, d) {
  81.         var s=1.70158;var p=0;var a=c;
  82.         if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
  83.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  84.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  85.         return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  86.     },
  87.     inOutElastic: function (t, b, c, d) {
  88.         var s=1.70158;var p=0;var a=c;
  89.         if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
  90.         if (a < Math.abs(c)) { a=c; var s=p/4; }
  91.         else var s = p/(2*Math.PI) * Math.asin (c/a);
  92.         if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
  93.         return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
  94.     },
  95.     inBack: function (t, b, c, d, s) {
  96.         if (s == undefined) s = 1.70158;
  97.         return c*(t/=d)*t*((s+1)*t - s) + b;
  98.     },
  99.     outBack: function (t, b, c, d, s) {
  100.         if (s == undefined) s = 1.70158;
  101.         return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
  102.     },
  103.     inOutBack: function (t, b, c, d, s) {
  104.         if (s == undefined) s = 1.70158;
  105.         if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
  106.         return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
  107.     },
  108.     inBounce: function (t, b, c, d) {
  109.         return c - Ease.outBounce (d-t, 0, c, d) + b;
  110.     },
  111.     outBounce: function (t, b, c, d) {
  112.         if ((t/=d) < (1/2.75)) {
  113.             return c*(7.5625*t*t) + b;
  114.         } else if (t < (2/2.75)) {
  115.             return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
  116.         } else if (t < (2.5/2.75)) {
  117.             return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
  118.         } else {
  119.             return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
  120.         }
  121.     },
  122.     inOutBounce: function (t, b, c, d) {
  123.         if (t < d/2) return Ease.inBounce (t*2, 0, c, d) * .5 + b;
  124.         return Ease.outBounce (t*2-d, 0, c, d) * .5 + c*.5 + b;
  125.     }
  126. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement