// 转换为left/top体系
function getPosition(target) {
  var rect = target.getBoundingClientRect();
  var style = window.getComputedStyle(target);

  // 横向转换
  var left = rect.left;
  if (style.left !== 'auto' && style.right === 'auto') {
    left = parseFloat(style.left) || 0;
  } else if (style.right !== 'auto') {
    left = window.innerWidth - parseFloat(style.right) - rect.width;
  }

  // 纵向转换
  var top = rect.top;
  if (style.top !== 'auto' && style.bottom === 'auto') {
    top = parseFloat(style.top) || 0;
  } else if (style.bottom !== 'auto') {
    top = window.innerHeight - parseFloat(style.bottom) - rect.height;
  }

  // 清除冲突定位
  target.style.left = "".concat(left, "px");
  target.style.top = "".concat(top, "px");
  target.style.right = 'auto';
  target.style.bottom = 'auto';
  return {
    left: left,
    top: top
  };
}
export default getPosition;