function calculateOffset(object) {
            var currentLeft = 0,
              currentTop = 0;
            if (object.offsetParent) {
              do {
                currentLeft += object.offsetLeft;
                currentTop += object.offsetTop;
              } while ((object = object.offsetParent));
            } else {
              currentLeft += object.offsetLeft;
              currentTop += object.offsetTop;
            }
            return [currentLeft, currentTop];
          }
Helper fxn to measure ascent and descent.
Adapted from http://stackoverflow.com/a/25355178