title: CreateJS - scaling the canvas does not scale the mouse coordinates
body: <p>I am working on a big project where exercises in Canvas are created through JSON-data and CreateJS. The purpose of having it in HTML 5 is to not have to use a separate app for your phone, you can always use the website. </p>
  
  <p>Everything works fine, however in mobile the Canvas is rescaled to full screen. This is done through checking the screen size, and if it's small enough to be mobile the canvas is scaled through this code:</p>
  
  <pre><code>// browser viewport size
  var w = window.innerWidth;
  var h = window.innerHeight;
  
  // stage dimensions
  var ow = canvasWidth;
  var oh = canvasHeight;
  
  // keep aspect ratio
  var scale = Math.min(w / ow, h / oh);
  stage.scaleX = scale;
  stage.scaleY = scale;
  
  // adjust canvas size
  stage.canvas.width = ow * scale;
  stage.canvas.height = oh * scale;
  </code></pre>
  
  <p>This works great for most of the exercises, like quizzes and such, where all you have to do is click on a button. However we also have some drag and drop-exercises, and an exercise where you can color a drawing. These of course rely on the mouse coordinates to work properly. The problem is, when the canvas is scaled the mouse coordinates are <strong>not</strong>. So when you drag an item or try to draw, there is an offset happening. So your drawing appears way left of your click, and when picking up a draggable object it doesn't quite follow your click correctly.</p>
  
  <p>Had I made the code from the beginning I'm fairly sure how I would have recalculated the coordinates, but since they are calculated by CreateJS I don't really know how I should go about this.</p>
  
  <p>This was reported as a problem by someone about a year ago <a href="https://github.com/CreateJS/EaselJS/issues/477" rel="nofollow">here</a>, where this solution was suggested:</p>
  
  <blockquote>
    <p>I was able to work around this by adding a top-level container and attaching my Bitmaps to that and scaling it.</p>
  </blockquote>
  
  <p>The whole exercise is inside a container which I have tried to scale but to no avail. I have also tried sending the scale as a parameter to the parts of the exercise created (for example the menu, background images and such) and not scale it all together, and it seems to work okay since then I can exclude the drawing layer. But since it is a large project and many different exercises and parts to be scaled it would take quite some time to implement, and I'm not sure it's a viable solution. </p>
  
  <p>Is there a good and easy way to rescale the mouse coordinates along with the canvas size in CreateJS? I have found pure Javascript examples here on SO, but nothing for CreateJS in particular.</p>