title: Receiving transformed mouse event data from DOM objects with a CSS 3D transform
body: <p>Is there currently any data in a javascript mouse event that would allow me to easily find or calculate a mouse position relative to the 3D space of a transformed element?  </p>
  
  <p>To illustrate visually,<br>
  At left is the div without a 3d matrix, at right is the div after 3d transformation.<br>
  <code>o</code> is the origin of the mouse event</p>
  
  <pre><code>                +
                 /|
                / |
  +-----+      +  |
  |     |      |  |
  |    o|  =&gt;  | o|
  |     |      |  |
  +-----+      +  |
                \ |
                 \|
                  +
  </code></pre>
  
  <p>In the script below, clicking the same pixels in the div will report an <code>event.layerX</code> which is in the 2d transformation space of the document/screen.  </p>
  
  <p>I'm aware, but not thrilled about the prospect of parsing the div's matrix3d and using that to multiply to the event position to discover this, however in the real implementation, the divs will have more complex transformations and this would need to be done on every frame for more than one object and I worry about the overhead that would bring...I certainly wouldn't mind help with that if it's my only option though.  </p>
  
  <pre><code>&lt;!doctype html&gt;  
  
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;meta charset='utf-8'&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;style type="text/css" media="screen"&gt;
  
          body {
              background-color: #FFF;
          }
  
          img {
              position: absolute;
          }
  
          #main {
              margin: 0;
              -webkit-perspective: 1800;
          }
  
          #card {
              position: relative;
              margin: 0 auto;
              width: 420px;
              height: 562px;
              -webkit-transform-style: preserve-3d;
              -webkit-transform-origin: center center;
          }
  
          #card .page {
              position: absolute;
              -webkit-transform-style: preserve-3d;
              -webkit-transform-origin: left center;
          }
  
          #card .page .face {
              position: absolute;
              width: 100%;
              height: 100%;
              -webkit-transform-style: flat;
          }
          #card .page .face.front {
              z-index: 1;
              -webkit-backface-visibility: hidden;
          }
          #card .page .face.back {
              -webkit-transform: rotateY(180deg) translateX(-420px);
          }
  
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id='main'&gt;
          &lt;div id='card'&gt;
              &lt;div class='page draggable'&gt;
                  &lt;div class='face front'&gt;
                      &lt;img src='front.jpg'/&gt;
                  &lt;/div&gt;
                  &lt;div class='face back'&gt;
                      &lt;img src='back.jpg'/&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;script src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'&gt;&lt;/script&gt;
      &lt;script&gt;
  
  
          function rotate() {
              $('.page').css("-webkit-transform", "rotate3d(0, -1, 0, 60deg)");
              $('.page').mousedown(function(event) {
                  console.log(event.layerX);
              });
          }
  
          $(document).ready(function() {
              rotate();
          });
  
      &lt;/script&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>