title: Detecting both left and right mouse movement and no movement
body: <p>I'm trying to detect three mouse movement states in this (modified) <a href="https://stackoverflow.com/questions/8575951/jquery-mouse-direction-plugin">jQuery plugin</a> – left, right and stop (mouse not moving):</p>
  
  <pre><code>(function ($) {
      var options = {};
      var oldx = 0;
      var direction = "";
      $.mousedirection = function (opts) {
          var defaults = {};
          options = $.extend(defaults, opts);
          $(document).bind("mousemove", function (e) {
              var activeElement = e.target || e.srcElement;
              if (e.pageX == oldx) {
                  direction = "stop";
              } else if (e.pageX &gt; oldx) {
                  direction = "right";
              } else if (e.pageX &lt; oldx) {
                  direction = "left";
              }
              $(activeElement).trigger(direction);
              $(activeElement).trigger({
                  type: "mousedirection",
                  direction: direction
              });
              oldx = e.pageX;
          });
      }
  })(jQuery)
  
  $(function () {
      $.mousedirection();
      $(".container").bind("mousedirection", function (e) {
          $(this).html("Mouse Direction: &lt;b&gt;" + e.direction + "&lt;/b&gt;");
      });
  });
  </code></pre>
  
  <p>But it doesn't work as expected. I believe there should be some kind of minimal delay between firing of subsequent checks in <code>mousemove</code> function but I'm not sure how to implement it.</p>
  
  <p><a href="http://jsfiddle.net/fallenartist/7pBE7/1/" rel="nofollow noreferrer">http://jsfiddle.net/fallenartist/7pBE7/1/</a> - mostly in 'stop' state, not detecting properly 'left' and 'right' mouse movement</p>
  
  <p>Thanks a million.</p>