code: function getPosition(el) {
    var offsetParent = getOffsetParent(el);
    var ps = {
      x: el.offsetLeft,
      y: el.offsetTop
    };
    var parent = el;
  
    while (true) {
      parent = parent.parentElement;
  
      if (parent === offsetParent || !parent) {
        break;
      }
  
      ps.x -= parent.scrollLeft;
      ps.y -= parent.scrollTop;
    }
  
    return ps;
  }
docs: get el current position. like jQuery.position the position is relative to offsetParent viewport left top. it is for set absolute position, absolute position is relative to offsetParent viewport left top. 相对于offsetParent可视区域左上角(el.offsetLeft或top包含父元素的滚动距离, 所以要减去). position一般用于设置绝对定位的情况, 而绝对定位就是以可视区域左上角为原点.