code: function getRect(elem) {
    if (elem && !elem.nodeType) {
      elem = elem[0];
    }
  
    if (!elem || 1 !== elem.nodeType) {
      return false;
    }
  
    var bounds = elem.getBoundingClientRect();
  
    return {
      height: bounds.bottom - bounds.top,
      width: bounds.right - bounds.left,
      top: bounds.top,
      left: bounds.left
    };
  }
docs: Calculate the rectangle of the element with an optional buffer.
  @param {Element} elem The element.
  @param {number} buffer An extra padding.