title: Detect mouse direction - JavaScript
body: <pre><code>var direction = ""
  var mousemovemethod = function (e) {
      var oldx = 0;
      if (e.movementX &lt; oldx) {
          direction = "left"
      } else if (e.movementX &gt; oldx) {
          direction = "right"
      }
      oldx = e.pageX;
  }
  </code></pre>
  
  <p>This is how I detect the mouse direction and it works so good but it works only on Chrome, how I can make this compatible with other browsers (Firefox, Opera and at least ie8+ or ie9+).
  No jQuery please.</p>