code: function _screenOffset(element) {
          var elemBounds = element.getBoundingClientRect(),
              body = window.document.body,
              offsetTop,
              offsetLeft;
  
          if (window.getComputedStyle(body).position === "static") {
              offsetLeft = elemBounds.left + window.pageXOffset;
              offsetTop = elemBounds.top + window.pageYOffset;
          } else {
              var bodyBounds = body.getBoundingClientRect();
              offsetLeft = elemBounds.left - bodyBounds.left;
              offsetTop = elemBounds.top - bodyBounds.top;
          }
          return { left: offsetLeft, top: offsetTop };
      }
docs: compute the screen offset of an element