title: Pure JavaScript animation easing
body: <p>I've been trying to find a pure JavaScript ease implementation for some hours, but couldn't find any. The ones that came close didn't make any sense. All I could find was bunch of easing functions without implementation.</p>
  
  <p>For example, functions like these:</p>
  
  <pre><code>function linear(time, begin, change, duration) {
      return change * time / duration + begin;
  }
  
  function easeInQuad(t) {
      return t*t
  },
  
  function easeOutQuad(t) {
      return t*(2-t)
  },
  </code></pre>
  
  <p>One of the things that trouble me is where does fps come in to play? It's directly related to the duration. I've seen no mention of it.</p>
  
  <p>How would I implement the above easing functions in the following animation?</p>
  
  <p><a href="https://jsfiddle.net/akinuri/4k4qzwkd/" rel="noreferrer">JSFiddle</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var box = document.getElementById("box");
  
  var fps  = 60;
  var duration = 2; // seconds
  var start = 0; // pixel
  var finish = window.innerWidth - box.clientWidth;
  var distance = finish - start;
  var increment = distance / (duration * fps);
  
  var position = start;
  
  function move() {
    position += increment;
    if (position &gt;= finish) {
      clearInterval(handler);
      box.style.left = finish + "px";
      return;
    }
    box.style.left = position + "px";
  }
  
  var handler = setInterval(move, 1000 / fps);</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    background: gainsboro;
  }
  #box {
    width: 100px;
    height: 100px;
    background: white;
    box-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
    position: absolute;
    left: 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="box"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>