title: Best way to run mousemove only on mousedown with pure javascript?
body: <p>I do not want any unnecessary loops occurring for <code>mousemove</code> event. So I became interested, in terms of performance/best practice what would be the best way to run <code>mousemove</code> only while <code>mousedown == true</code>? Currently I'm using: </p>
  
  <pre><code>var pressedMouse = false;
  
  myObject.addEventListener("mousedown", function(e){
  
      mouseDownFunction(e); 
      pressedMouse = true;
  
      myObject.onmousemove = function(e) {
          if(pressedMouse == true){
              mouseMoveFunction(e);
          }
       }
  });
  
  myObject.addEventListener("mouseup", function(e){
      pressedMouse = false;
  });
  </code></pre>
  
  <p><code>mouseMoveFunction()</code> isn't being called because of the <code>pressedMouse</code> variable. Can <code>onmousemove</code> event be prevented from firing if <code>mousedown</code> not in use? </p>