keydragzoom/src/keydragzoom.js
function (h) {
    var posX = h.offsetLeft;
    var posY = h.offsetTop;
    var parent = h.offsetParent;
    // Add offsets for all ancestors in the hierarchy
    while (parent !== null) {
      // Adjust for scrolling elements which may affect the map position.
      //
      // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific
      //
      // "...make sure that every element [on a Web page] with an overflow
      // of anything other than visible also has a position style set to
      // something other than the default static..."
      if (parent !== document.body && parent !== document.documentElement) {
        posX -= parent.scrollLeft;
        posY -= parent.scrollTop;
      }
      // See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5
      // Example: http://notebook.kulchenko.com/maps/gridmove
      var m = parent;
      // This is the "normal" way to get offset information:
      var moffx = m.offsetLeft;
      var moffy = m.offsetTop;
      // This covers those cases where a transform is used:
      if (!moffx && !moffy && window.getComputedStyle) {
        var matrix = document.defaultView.getComputedStyle(m, null).MozTransform ||
        document.defaultView.getComputedStyle(m, null).WebkitTransform;
        if (matrix) {
          if (typeof matrix === "string") {
            var parms = matrix.split(",");
            moffx += parseInt(parms[4], 10) || 0;
            moffy += parseInt(parms[5], 10) || 0;
          }
        }
      }
      posX += moffx;
      posY += moffy;
      parent = parent.offsetParent;
    }
    return {
      left: posX,
      top: posY
    };
  }
function (h) {
    var posX = h.offsetLeft;
    var posY = h.offsetTop;
    var parent = h.offsetParent;
    // Add offsets for all ancestors in the hierarchy
    while (parent !== null) {
      // Adjust for scrolling elements which may affect the map position.
      //
      // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific
      //
      // "...make sure that every element [on a Web page] with an overflow
      // of anything other than visible also has a position style set to
      // something other than the default static..."
      if (parent !== document.body && parent !== document.documentElement) {
        posX -= parent.scrollLeft;
        posY -= parent.scrollTop;
      }
      // See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5
      // Example: http://notebook.kulchenko.com/maps/gridmove
      var m = parent;
      // This is the "normal" way to get offset information:
      var moffx = m.offsetLeft;
      var moffy = m.offsetTop;
      // This covers those cases where a transform is used:
      if (!moffx && !moffy && window.getComputedStyle) {
        var matrix = document.defaultView.getComputedStyle(m, null).MozTransform ||
        document.defaultView.getComputedStyle(m, null).WebkitTransform;
        if (matrix) {
          if (typeof matrix === "string") {
            var parms = matrix.split(",");
            moffx += parseInt(parms[4], 10) || 0;
            moffy += parseInt(parms[5], 10) || 0;
          }
        }
      }
      posX += moffx;
      posY += moffy;
      parent = parent.offsetParent;
    }
    return {
      left: posX,
      top: posY
    };
  }
function ( h ) { var posX = h . offsetLeft ; var posY = h . offsetTop ; var parent = h . offsetParent ; // Add offsets for all ancestors in the hierarchy
 while ( parent !== null ) { // Adjust for scrolling elements which may affect the map position.
 //
 // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific
 //
 // "...make sure that every element [on a Web page] with an overflow
 // of anything other than visible also has a position style set to
 // something other than the default static..."
 if ( parent !== document . body && parent !== document . documentElement ) { posX -= parent . scrollLeft ; posY -= parent . scrollTop ; } // See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5
 // Example: http://notebook.kulchenko.com/maps/gridmove
 var m = parent ; // This is the "normal" way to get offset information:
 var moffx = m . offsetLeft ; var moffy = m . offsetTop ; // This covers those cases where a transform is used:
 if ( ! moffx && ! moffy && window . getComputedStyle ) { var matrix = document . defaultView . getComputedStyle ( m , null ) . MozTransform || document . defaultView . getComputedStyle ( m , null ) . WebkitTransform ; if ( matrix ) { if ( typeof matrix === "string" ) { var parms = matrix . split ( "," ) ; moffx += parseInt ( parms [ 4 ] , 10 ) || 0 ; moffy += parseInt ( parms [ 5 ] , 10 ) || 0 ; } } } posX += moffx ; posY += moffy ; parent = parent . offsetParent ; } return { left : posX , top : posY } ; }
Get the position of an HTML element relative to the document.
@param {Node} h  The HTML element.
@return {Object} The position object {left, top}.
Get the position of an HTML element relative to the document .