module.exports = { /** * 根据参数 html标签返回 左上角到 浏览器窗口的距离 * @param ele * @returns {*[]} */ getAbsoluteDistance: function (ele) { var top = ele.offsetTop; var left = ele.offsetLeft; var bottom = 0; var right = 0; var o = ele.offsetParent; while (o != null) { top += o.offsetTop; left += o.offsetLeft; o = o.offsetParent;
} top -= $(window).scrollTop(); bottom = $(window).height() - top; left -= $(window).scrollLeft(); right = $(window).width() - left; return { 'top': top, 'right': right, 'bottom': bottom, 'left': left }
}
};